
obj/user/lsfd:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 67 01 00 00       	call   800198 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <usage>:
#include <inc/lib.h>

void
usage(void)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	83 ec 18             	sub    $0x18,%esp
	cprintf("usage: lsfd [-1]\n");
  800046:	c7 04 24 80 2a 80 00 	movl   $0x802a80,(%esp)
  80004d:	e8 77 02 00 00       	call   8002c9 <cprintf>
	exit();
  800052:	e8 91 01 00 00       	call   8001e8 <exit>
}
  800057:	c9                   	leave  
  800058:	c3                   	ret    

00800059 <umain>:

void
umain(int argc, char **argv)
{
  800059:	55                   	push   %ebp
  80005a:	89 e5                	mov    %esp,%ebp
  80005c:	57                   	push   %edi
  80005d:	56                   	push   %esi
  80005e:	53                   	push   %ebx
  80005f:	81 ec cc 00 00 00    	sub    $0xcc,%esp
  800065:	8b 45 0c             	mov    0xc(%ebp),%eax
	int i, usefprint = 0;
	struct Stat st;

	ARGBEGIN{
  800068:	85 c0                	test   %eax,%eax
  80006a:	8d 55 08             	lea    0x8(%ebp),%edx
  80006d:	0f 44 c2             	cmove  %edx,%eax
  800070:	83 3d 78 60 80 00 00 	cmpl   $0x0,0x806078
  800077:	75 08                	jne    800081 <umain+0x28>
  800079:	8b 10                	mov    (%eax),%edx
  80007b:	89 15 78 60 80 00    	mov    %edx,0x806078
  800081:	83 c0 04             	add    $0x4,%eax
  800084:	89 85 54 ff ff ff    	mov    %eax,-0xac(%ebp)
  80008a:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  80008e:	8b 18                	mov    (%eax),%ebx
  800090:	85 db                	test   %ebx,%ebx
  800092:	74 29                	je     8000bd <umain+0x64>
  800094:	80 3b 2d             	cmpb   $0x2d,(%ebx)
  800097:	75 24                	jne    8000bd <umain+0x64>
  800099:	83 c3 01             	add    $0x1,%ebx
  80009c:	0f b6 03             	movzbl (%ebx),%eax
  80009f:	84 c0                	test   %al,%al
  8000a1:	74 1a                	je     8000bd <umain+0x64>
  8000a3:	be 00 00 00 00       	mov    $0x0,%esi
  8000a8:	bf 01 00 00 00       	mov    $0x1,%edi
  8000ad:	3c 2d                	cmp    $0x2d,%al
  8000af:	75 28                	jne    8000d9 <umain+0x80>
  8000b1:	80 7b 01 00          	cmpb   $0x0,0x1(%ebx)
  8000b5:	75 22                	jne    8000d9 <umain+0x80>
  8000b7:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  8000bb:	eb 05                	jmp    8000c2 <umain+0x69>
  8000bd:	be 00 00 00 00       	mov    $0x0,%esi
  8000c2:	bb 00 00 00 00       	mov    $0x0,%ebx
		usefprint = 1;
		break;
	}ARGEND

	for (i = 0; i < 32; i++)
		if (fstat(i, &st) >= 0) {
  8000c7:	8d bd 5c ff ff ff    	lea    -0xa4(%ebp),%edi
  8000cd:	eb 3f                	jmp    80010e <umain+0xb5>
	int i, usefprint = 0;
	struct Stat st;

	ARGBEGIN{
	default:
		usage();
  8000cf:	e8 6c ff ff ff       	call   800040 <usage>
umain(int argc, char **argv)
{
	int i, usefprint = 0;
	struct Stat st;

	ARGBEGIN{
  8000d4:	83 c3 01             	add    $0x1,%ebx
  8000d7:	89 fe                	mov    %edi,%esi
  8000d9:	0f b6 03             	movzbl (%ebx),%eax
  8000dc:	84 c0                	test   %al,%al
  8000de:	74 06                	je     8000e6 <umain+0x8d>
  8000e0:	3c 31                	cmp    $0x31,%al
  8000e2:	75 eb                	jne    8000cf <umain+0x76>
  8000e4:	eb ee                	jmp    8000d4 <umain+0x7b>
  8000e6:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  8000ea:	83 85 54 ff ff ff 04 	addl   $0x4,-0xac(%ebp)
  8000f1:	8b 85 54 ff ff ff    	mov    -0xac(%ebp),%eax
  8000f7:	8b 18                	mov    (%eax),%ebx
  8000f9:	85 db                	test   %ebx,%ebx
  8000fb:	74 c5                	je     8000c2 <umain+0x69>
  8000fd:	80 3b 2d             	cmpb   $0x2d,(%ebx)
  800100:	75 c0                	jne    8000c2 <umain+0x69>
  800102:	83 c3 01             	add    $0x1,%ebx
  800105:	0f b6 03             	movzbl (%ebx),%eax
  800108:	84 c0                	test   %al,%al
  80010a:	75 a1                	jne    8000ad <umain+0x54>
  80010c:	eb b4                	jmp    8000c2 <umain+0x69>
		usefprint = 1;
		break;
	}ARGEND

	for (i = 0; i < 32; i++)
		if (fstat(i, &st) >= 0) {
  80010e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800112:	89 1c 24             	mov    %ebx,(%esp)
  800115:	e8 85 12 00 00       	call   80139f <fstat>
  80011a:	85 c0                	test   %eax,%eax
  80011c:	78 66                	js     800184 <umain+0x12b>
			if (usefprint)
  80011e:	85 f6                	test   %esi,%esi
  800120:	74 36                	je     800158 <umain+0xff>
				fprintf(1, "fd %d: name %s isdir %d size %d dev %s\n",
  800122:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800125:	8b 40 04             	mov    0x4(%eax),%eax
  800128:	89 44 24 18          	mov    %eax,0x18(%esp)
  80012c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80012f:	89 44 24 14          	mov    %eax,0x14(%esp)
  800133:	8b 45 e0             	mov    -0x20(%ebp),%eax
  800136:	89 44 24 10          	mov    %eax,0x10(%esp)
  80013a:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  80013e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800142:	c7 44 24 04 94 2a 80 	movl   $0x802a94,0x4(%esp)
  800149:	00 
  80014a:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  800151:	e8 c3 1a 00 00       	call   801c19 <fprintf>
  800156:	eb 2c                	jmp    800184 <umain+0x12b>
					i, st.st_name, st.st_isdir,
					st.st_size, st.st_dev->dev_name);	
			else
				cprintf("fd %d: name %s isdir %d size %d dev %s\n",
  800158:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80015b:	8b 40 04             	mov    0x4(%eax),%eax
  80015e:	89 44 24 14          	mov    %eax,0x14(%esp)
  800162:	8b 45 dc             	mov    -0x24(%ebp),%eax
  800165:	89 44 24 10          	mov    %eax,0x10(%esp)
  800169:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80016c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800170:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800174:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800178:	c7 04 24 94 2a 80 00 	movl   $0x802a94,(%esp)
  80017f:	e8 45 01 00 00       	call   8002c9 <cprintf>
	case '1':
		usefprint = 1;
		break;
	}ARGEND

	for (i = 0; i < 32; i++)
  800184:	83 c3 01             	add    $0x1,%ebx
  800187:	83 fb 20             	cmp    $0x20,%ebx
  80018a:	75 82                	jne    80010e <umain+0xb5>
			else
				cprintf("fd %d: name %s isdir %d size %d dev %s\n",
					i, st.st_name, st.st_isdir,
					st.st_size, st.st_dev->dev_name);
		}
}
  80018c:	81 c4 cc 00 00 00    	add    $0xcc,%esp
  800192:	5b                   	pop    %ebx
  800193:	5e                   	pop    %esi
  800194:	5f                   	pop    %edi
  800195:	5d                   	pop    %ebp
  800196:	c3                   	ret    
	...

00800198 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800198:	55                   	push   %ebp
  800199:	89 e5                	mov    %esp,%ebp
  80019b:	83 ec 18             	sub    $0x18,%esp
  80019e:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8001a1:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8001a4:	8b 75 08             	mov    0x8(%ebp),%esi
  8001a7:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  8001aa:	e8 da 0f 00 00       	call   801189 <sys_getenvid>
	env = &envs [ENVX(envid)];
  8001af:	25 ff 03 00 00       	and    $0x3ff,%eax
  8001b4:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8001b7:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8001bc:	a3 74 60 80 00       	mov    %eax,0x806074

	// save the name of the program so that panic() can use it
	if (argc > 0)
  8001c1:	85 f6                	test   %esi,%esi
  8001c3:	7e 07                	jle    8001cc <libmain+0x34>
		binaryname = argv[0];
  8001c5:	8b 03                	mov    (%ebx),%eax
  8001c7:	a3 00 60 80 00       	mov    %eax,0x806000

	// call user main routine
	umain(argc, argv);
  8001cc:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8001d0:	89 34 24             	mov    %esi,(%esp)
  8001d3:	e8 81 fe ff ff       	call   800059 <umain>

	// exit gracefully
	exit();
  8001d8:	e8 0b 00 00 00       	call   8001e8 <exit>
}
  8001dd:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8001e0:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8001e3:	89 ec                	mov    %ebp,%esp
  8001e5:	5d                   	pop    %ebp
  8001e6:	c3                   	ret    
	...

008001e8 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  8001e8:	55                   	push   %ebp
  8001e9:	89 e5                	mov    %esp,%ebp
  8001eb:	83 ec 18             	sub    $0x18,%esp
	close_all();
  8001ee:	e8 66 15 00 00       	call   801759 <close_all>
	sys_env_destroy(0);
  8001f3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8001fa:	e8 be 0f 00 00       	call   8011bd <sys_env_destroy>
}
  8001ff:	c9                   	leave  
  800200:	c3                   	ret    
  800201:	00 00                	add    %al,(%eax)
	...

00800204 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  800204:	55                   	push   %ebp
  800205:	89 e5                	mov    %esp,%ebp
  800207:	53                   	push   %ebx
  800208:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  80020b:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  80020e:	a1 78 60 80 00       	mov    0x806078,%eax
  800213:	85 c0                	test   %eax,%eax
  800215:	74 10                	je     800227 <_panic+0x23>
		cprintf("%s: ", argv0);
  800217:	89 44 24 04          	mov    %eax,0x4(%esp)
  80021b:	c7 04 24 d3 2a 80 00 	movl   $0x802ad3,(%esp)
  800222:	e8 a2 00 00 00       	call   8002c9 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  800227:	8b 45 0c             	mov    0xc(%ebp),%eax
  80022a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80022e:	8b 45 08             	mov    0x8(%ebp),%eax
  800231:	89 44 24 08          	mov    %eax,0x8(%esp)
  800235:	a1 00 60 80 00       	mov    0x806000,%eax
  80023a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80023e:	c7 04 24 d8 2a 80 00 	movl   $0x802ad8,(%esp)
  800245:	e8 7f 00 00 00       	call   8002c9 <cprintf>
	vcprintf(fmt, ap);
  80024a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80024e:	8b 45 10             	mov    0x10(%ebp),%eax
  800251:	89 04 24             	mov    %eax,(%esp)
  800254:	e8 0f 00 00 00       	call   800268 <vcprintf>
	cprintf("\n");
  800259:	c7 04 24 90 2a 80 00 	movl   $0x802a90,(%esp)
  800260:	e8 64 00 00 00       	call   8002c9 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800265:	cc                   	int3   
  800266:	eb fd                	jmp    800265 <_panic+0x61>

00800268 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800268:	55                   	push   %ebp
  800269:	89 e5                	mov    %esp,%ebp
  80026b:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  800271:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800278:	00 00 00 
	b.cnt = 0;
  80027b:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  800282:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800285:	8b 45 0c             	mov    0xc(%ebp),%eax
  800288:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80028c:	8b 45 08             	mov    0x8(%ebp),%eax
  80028f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800293:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800299:	89 44 24 04          	mov    %eax,0x4(%esp)
  80029d:	c7 04 24 e3 02 80 00 	movl   $0x8002e3,(%esp)
  8002a4:	e8 d4 01 00 00       	call   80047d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8002a9:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8002af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002b3:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8002b9:	89 04 24             	mov    %eax,(%esp)
  8002bc:	e8 cf 0a 00 00       	call   800d90 <sys_cputs>

	return b.cnt;
}
  8002c1:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8002c7:	c9                   	leave  
  8002c8:	c3                   	ret    

008002c9 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  8002c9:	55                   	push   %ebp
  8002ca:	89 e5                	mov    %esp,%ebp
  8002cc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  8002cf:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  8002d2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002d6:	8b 45 08             	mov    0x8(%ebp),%eax
  8002d9:	89 04 24             	mov    %eax,(%esp)
  8002dc:	e8 87 ff ff ff       	call   800268 <vcprintf>
	va_end(ap);

	return cnt;
}
  8002e1:	c9                   	leave  
  8002e2:	c3                   	ret    

008002e3 <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  8002e3:	55                   	push   %ebp
  8002e4:	89 e5                	mov    %esp,%ebp
  8002e6:	53                   	push   %ebx
  8002e7:	83 ec 14             	sub    $0x14,%esp
  8002ea:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  8002ed:	8b 03                	mov    (%ebx),%eax
  8002ef:	8b 55 08             	mov    0x8(%ebp),%edx
  8002f2:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  8002f6:	83 c0 01             	add    $0x1,%eax
  8002f9:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  8002fb:	3d ff 00 00 00       	cmp    $0xff,%eax
  800300:	75 19                	jne    80031b <putch+0x38>
		sys_cputs(b->buf, b->idx);
  800302:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800309:	00 
  80030a:	8d 43 08             	lea    0x8(%ebx),%eax
  80030d:	89 04 24             	mov    %eax,(%esp)
  800310:	e8 7b 0a 00 00       	call   800d90 <sys_cputs>
		b->idx = 0;
  800315:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  80031b:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80031f:	83 c4 14             	add    $0x14,%esp
  800322:	5b                   	pop    %ebx
  800323:	5d                   	pop    %ebp
  800324:	c3                   	ret    
	...

00800330 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800330:	55                   	push   %ebp
  800331:	89 e5                	mov    %esp,%ebp
  800333:	57                   	push   %edi
  800334:	56                   	push   %esi
  800335:	53                   	push   %ebx
  800336:	83 ec 4c             	sub    $0x4c,%esp
  800339:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80033c:	89 d6                	mov    %edx,%esi
  80033e:	8b 45 08             	mov    0x8(%ebp),%eax
  800341:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800344:	8b 55 0c             	mov    0xc(%ebp),%edx
  800347:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80034a:	8b 45 10             	mov    0x10(%ebp),%eax
  80034d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800350:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800353:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800356:	b9 00 00 00 00       	mov    $0x0,%ecx
  80035b:	39 d1                	cmp    %edx,%ecx
  80035d:	72 15                	jb     800374 <printnum+0x44>
  80035f:	77 07                	ja     800368 <printnum+0x38>
  800361:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800364:	39 d0                	cmp    %edx,%eax
  800366:	76 0c                	jbe    800374 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800368:	83 eb 01             	sub    $0x1,%ebx
  80036b:	85 db                	test   %ebx,%ebx
  80036d:	8d 76 00             	lea    0x0(%esi),%esi
  800370:	7f 61                	jg     8003d3 <printnum+0xa3>
  800372:	eb 70                	jmp    8003e4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800374:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800378:	83 eb 01             	sub    $0x1,%ebx
  80037b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80037f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800383:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800387:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80038b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80038e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800391:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800394:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800398:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80039f:	00 
  8003a0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8003a3:	89 04 24             	mov    %eax,(%esp)
  8003a6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8003a9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8003ad:	e8 4e 24 00 00       	call   802800 <__udivdi3>
  8003b2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8003b5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  8003b8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8003bc:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8003c0:	89 04 24             	mov    %eax,(%esp)
  8003c3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8003c7:	89 f2                	mov    %esi,%edx
  8003c9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8003cc:	e8 5f ff ff ff       	call   800330 <printnum>
  8003d1:	eb 11                	jmp    8003e4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  8003d3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003d7:	89 3c 24             	mov    %edi,(%esp)
  8003da:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8003dd:	83 eb 01             	sub    $0x1,%ebx
  8003e0:	85 db                	test   %ebx,%ebx
  8003e2:	7f ef                	jg     8003d3 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  8003e4:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003e8:	8b 74 24 04          	mov    0x4(%esp),%esi
  8003ec:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8003ef:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003f3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8003fa:	00 
  8003fb:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8003fe:	89 14 24             	mov    %edx,(%esp)
  800401:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800404:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800408:	e8 23 25 00 00       	call   802930 <__umoddi3>
  80040d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800411:	0f be 80 f4 2a 80 00 	movsbl 0x802af4(%eax),%eax
  800418:	89 04 24             	mov    %eax,(%esp)
  80041b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80041e:	83 c4 4c             	add    $0x4c,%esp
  800421:	5b                   	pop    %ebx
  800422:	5e                   	pop    %esi
  800423:	5f                   	pop    %edi
  800424:	5d                   	pop    %ebp
  800425:	c3                   	ret    

00800426 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800426:	55                   	push   %ebp
  800427:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800429:	83 fa 01             	cmp    $0x1,%edx
  80042c:	7e 0e                	jle    80043c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80042e:	8b 10                	mov    (%eax),%edx
  800430:	8d 4a 08             	lea    0x8(%edx),%ecx
  800433:	89 08                	mov    %ecx,(%eax)
  800435:	8b 02                	mov    (%edx),%eax
  800437:	8b 52 04             	mov    0x4(%edx),%edx
  80043a:	eb 22                	jmp    80045e <getuint+0x38>
	else if (lflag)
  80043c:	85 d2                	test   %edx,%edx
  80043e:	74 10                	je     800450 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800440:	8b 10                	mov    (%eax),%edx
  800442:	8d 4a 04             	lea    0x4(%edx),%ecx
  800445:	89 08                	mov    %ecx,(%eax)
  800447:	8b 02                	mov    (%edx),%eax
  800449:	ba 00 00 00 00       	mov    $0x0,%edx
  80044e:	eb 0e                	jmp    80045e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800450:	8b 10                	mov    (%eax),%edx
  800452:	8d 4a 04             	lea    0x4(%edx),%ecx
  800455:	89 08                	mov    %ecx,(%eax)
  800457:	8b 02                	mov    (%edx),%eax
  800459:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80045e:	5d                   	pop    %ebp
  80045f:	c3                   	ret    

00800460 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800460:	55                   	push   %ebp
  800461:	89 e5                	mov    %esp,%ebp
  800463:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800466:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80046a:	8b 10                	mov    (%eax),%edx
  80046c:	3b 50 04             	cmp    0x4(%eax),%edx
  80046f:	73 0a                	jae    80047b <sprintputch+0x1b>
		*b->buf++ = ch;
  800471:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800474:	88 0a                	mov    %cl,(%edx)
  800476:	83 c2 01             	add    $0x1,%edx
  800479:	89 10                	mov    %edx,(%eax)
}
  80047b:	5d                   	pop    %ebp
  80047c:	c3                   	ret    

0080047d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80047d:	55                   	push   %ebp
  80047e:	89 e5                	mov    %esp,%ebp
  800480:	57                   	push   %edi
  800481:	56                   	push   %esi
  800482:	53                   	push   %ebx
  800483:	83 ec 5c             	sub    $0x5c,%esp
  800486:	8b 7d 08             	mov    0x8(%ebp),%edi
  800489:	8b 75 0c             	mov    0xc(%ebp),%esi
  80048c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80048f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800496:	eb 11                	jmp    8004a9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800498:	85 c0                	test   %eax,%eax
  80049a:	0f 84 f9 03 00 00    	je     800899 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8004a0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8004a4:	89 04 24             	mov    %eax,(%esp)
  8004a7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8004a9:	0f b6 03             	movzbl (%ebx),%eax
  8004ac:	83 c3 01             	add    $0x1,%ebx
  8004af:	83 f8 25             	cmp    $0x25,%eax
  8004b2:	75 e4                	jne    800498 <vprintfmt+0x1b>
  8004b4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  8004b8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  8004bf:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8004c6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8004cd:	b9 00 00 00 00       	mov    $0x0,%ecx
  8004d2:	eb 06                	jmp    8004da <vprintfmt+0x5d>
  8004d4:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  8004d8:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  8004da:	0f b6 13             	movzbl (%ebx),%edx
  8004dd:	0f b6 c2             	movzbl %dl,%eax
  8004e0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8004e3:	8d 43 01             	lea    0x1(%ebx),%eax
  8004e6:	83 ea 23             	sub    $0x23,%edx
  8004e9:	80 fa 55             	cmp    $0x55,%dl
  8004ec:	0f 87 8a 03 00 00    	ja     80087c <vprintfmt+0x3ff>
  8004f2:	0f b6 d2             	movzbl %dl,%edx
  8004f5:	ff 24 95 40 2c 80 00 	jmp    *0x802c40(,%edx,4)
  8004fc:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800500:	eb d6                	jmp    8004d8 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800502:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800505:	83 ea 30             	sub    $0x30,%edx
  800508:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80050b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80050e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800511:	83 fb 09             	cmp    $0x9,%ebx
  800514:	77 54                	ja     80056a <vprintfmt+0xed>
  800516:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800519:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80051c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80051f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800522:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800526:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800529:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80052c:	83 fb 09             	cmp    $0x9,%ebx
  80052f:	76 eb                	jbe    80051c <vprintfmt+0x9f>
  800531:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800534:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800537:	eb 31                	jmp    80056a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800539:	8b 55 14             	mov    0x14(%ebp),%edx
  80053c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80053f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800542:	8b 12                	mov    (%edx),%edx
  800544:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800547:	eb 21                	jmp    80056a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800549:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80054d:	ba 00 00 00 00       	mov    $0x0,%edx
  800552:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800556:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800559:	e9 7a ff ff ff       	jmp    8004d8 <vprintfmt+0x5b>
  80055e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800565:	e9 6e ff ff ff       	jmp    8004d8 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80056a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80056e:	0f 89 64 ff ff ff    	jns    8004d8 <vprintfmt+0x5b>
  800574:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800577:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80057a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80057d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800580:	e9 53 ff ff ff       	jmp    8004d8 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800585:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800588:	e9 4b ff ff ff       	jmp    8004d8 <vprintfmt+0x5b>
  80058d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800590:	8b 45 14             	mov    0x14(%ebp),%eax
  800593:	8d 50 04             	lea    0x4(%eax),%edx
  800596:	89 55 14             	mov    %edx,0x14(%ebp)
  800599:	89 74 24 04          	mov    %esi,0x4(%esp)
  80059d:	8b 00                	mov    (%eax),%eax
  80059f:	89 04 24             	mov    %eax,(%esp)
  8005a2:	ff d7                	call   *%edi
  8005a4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8005a7:	e9 fd fe ff ff       	jmp    8004a9 <vprintfmt+0x2c>
  8005ac:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8005af:	8b 45 14             	mov    0x14(%ebp),%eax
  8005b2:	8d 50 04             	lea    0x4(%eax),%edx
  8005b5:	89 55 14             	mov    %edx,0x14(%ebp)
  8005b8:	8b 00                	mov    (%eax),%eax
  8005ba:	89 c2                	mov    %eax,%edx
  8005bc:	c1 fa 1f             	sar    $0x1f,%edx
  8005bf:	31 d0                	xor    %edx,%eax
  8005c1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8005c3:	83 f8 12             	cmp    $0x12,%eax
  8005c6:	7f 0b                	jg     8005d3 <vprintfmt+0x156>
  8005c8:	8b 14 85 a0 2d 80 00 	mov    0x802da0(,%eax,4),%edx
  8005cf:	85 d2                	test   %edx,%edx
  8005d1:	75 20                	jne    8005f3 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  8005d3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8005d7:	c7 44 24 08 05 2b 80 	movl   $0x802b05,0x8(%esp)
  8005de:	00 
  8005df:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005e3:	89 3c 24             	mov    %edi,(%esp)
  8005e6:	e8 36 03 00 00       	call   800921 <printfmt>
  8005eb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8005ee:	e9 b6 fe ff ff       	jmp    8004a9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  8005f3:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8005f7:	c7 44 24 08 f2 2e 80 	movl   $0x802ef2,0x8(%esp)
  8005fe:	00 
  8005ff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800603:	89 3c 24             	mov    %edi,(%esp)
  800606:	e8 16 03 00 00       	call   800921 <printfmt>
  80060b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80060e:	e9 96 fe ff ff       	jmp    8004a9 <vprintfmt+0x2c>
  800613:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800616:	89 c3                	mov    %eax,%ebx
  800618:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80061b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80061e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800621:	8b 45 14             	mov    0x14(%ebp),%eax
  800624:	8d 50 04             	lea    0x4(%eax),%edx
  800627:	89 55 14             	mov    %edx,0x14(%ebp)
  80062a:	8b 00                	mov    (%eax),%eax
  80062c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80062f:	85 c0                	test   %eax,%eax
  800631:	b8 0e 2b 80 00       	mov    $0x802b0e,%eax
  800636:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80063a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80063d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800641:	7e 06                	jle    800649 <vprintfmt+0x1cc>
  800643:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800647:	75 13                	jne    80065c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800649:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80064c:	0f be 02             	movsbl (%edx),%eax
  80064f:	85 c0                	test   %eax,%eax
  800651:	0f 85 9b 00 00 00    	jne    8006f2 <vprintfmt+0x275>
  800657:	e9 88 00 00 00       	jmp    8006e4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80065c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800660:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800663:	89 0c 24             	mov    %ecx,(%esp)
  800666:	e8 00 03 00 00       	call   80096b <strnlen>
  80066b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80066e:	29 c2                	sub    %eax,%edx
  800670:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800673:	85 d2                	test   %edx,%edx
  800675:	7e d2                	jle    800649 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800677:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  80067b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  80067e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800681:	89 d3                	mov    %edx,%ebx
  800683:	89 74 24 04          	mov    %esi,0x4(%esp)
  800687:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80068a:	89 04 24             	mov    %eax,(%esp)
  80068d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80068f:	83 eb 01             	sub    $0x1,%ebx
  800692:	85 db                	test   %ebx,%ebx
  800694:	7f ed                	jg     800683 <vprintfmt+0x206>
  800696:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800699:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8006a0:	eb a7                	jmp    800649 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8006a2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8006a6:	74 1a                	je     8006c2 <vprintfmt+0x245>
  8006a8:	8d 50 e0             	lea    -0x20(%eax),%edx
  8006ab:	83 fa 5e             	cmp    $0x5e,%edx
  8006ae:	76 12                	jbe    8006c2 <vprintfmt+0x245>
					putch('?', putdat);
  8006b0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8006b4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  8006bb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8006be:	66 90                	xchg   %ax,%ax
  8006c0:	eb 0a                	jmp    8006cc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8006c2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8006c6:	89 04 24             	mov    %eax,(%esp)
  8006c9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8006cc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  8006d0:	0f be 03             	movsbl (%ebx),%eax
  8006d3:	85 c0                	test   %eax,%eax
  8006d5:	74 05                	je     8006dc <vprintfmt+0x25f>
  8006d7:	83 c3 01             	add    $0x1,%ebx
  8006da:	eb 29                	jmp    800705 <vprintfmt+0x288>
  8006dc:	89 fe                	mov    %edi,%esi
  8006de:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8006e1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8006e4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8006e8:	7f 2e                	jg     800718 <vprintfmt+0x29b>
  8006ea:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8006ed:	e9 b7 fd ff ff       	jmp    8004a9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8006f2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8006f5:	83 c2 01             	add    $0x1,%edx
  8006f8:	89 7d e0             	mov    %edi,-0x20(%ebp)
  8006fb:	89 f7                	mov    %esi,%edi
  8006fd:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800700:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800703:	89 d3                	mov    %edx,%ebx
  800705:	85 f6                	test   %esi,%esi
  800707:	78 99                	js     8006a2 <vprintfmt+0x225>
  800709:	83 ee 01             	sub    $0x1,%esi
  80070c:	79 94                	jns    8006a2 <vprintfmt+0x225>
  80070e:	89 fe                	mov    %edi,%esi
  800710:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800713:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800716:	eb cc                	jmp    8006e4 <vprintfmt+0x267>
  800718:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80071b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80071e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800722:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800729:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80072b:	83 eb 01             	sub    $0x1,%ebx
  80072e:	85 db                	test   %ebx,%ebx
  800730:	7f ec                	jg     80071e <vprintfmt+0x2a1>
  800732:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800735:	e9 6f fd ff ff       	jmp    8004a9 <vprintfmt+0x2c>
  80073a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80073d:	83 f9 01             	cmp    $0x1,%ecx
  800740:	7e 16                	jle    800758 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800742:	8b 45 14             	mov    0x14(%ebp),%eax
  800745:	8d 50 08             	lea    0x8(%eax),%edx
  800748:	89 55 14             	mov    %edx,0x14(%ebp)
  80074b:	8b 10                	mov    (%eax),%edx
  80074d:	8b 48 04             	mov    0x4(%eax),%ecx
  800750:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800753:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800756:	eb 32                	jmp    80078a <vprintfmt+0x30d>
	else if (lflag)
  800758:	85 c9                	test   %ecx,%ecx
  80075a:	74 18                	je     800774 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80075c:	8b 45 14             	mov    0x14(%ebp),%eax
  80075f:	8d 50 04             	lea    0x4(%eax),%edx
  800762:	89 55 14             	mov    %edx,0x14(%ebp)
  800765:	8b 00                	mov    (%eax),%eax
  800767:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80076a:	89 c1                	mov    %eax,%ecx
  80076c:	c1 f9 1f             	sar    $0x1f,%ecx
  80076f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800772:	eb 16                	jmp    80078a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800774:	8b 45 14             	mov    0x14(%ebp),%eax
  800777:	8d 50 04             	lea    0x4(%eax),%edx
  80077a:	89 55 14             	mov    %edx,0x14(%ebp)
  80077d:	8b 00                	mov    (%eax),%eax
  80077f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800782:	89 c2                	mov    %eax,%edx
  800784:	c1 fa 1f             	sar    $0x1f,%edx
  800787:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80078a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80078d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800790:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800795:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800799:	0f 89 9b 00 00 00    	jns    80083a <vprintfmt+0x3bd>
				putch('-', putdat);
  80079f:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007a3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8007aa:	ff d7                	call   *%edi
				num = -(long long) num;
  8007ac:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8007af:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8007b2:	f7 d9                	neg    %ecx
  8007b4:	83 d3 00             	adc    $0x0,%ebx
  8007b7:	f7 db                	neg    %ebx
  8007b9:	b8 0a 00 00 00       	mov    $0xa,%eax
  8007be:	eb 7a                	jmp    80083a <vprintfmt+0x3bd>
  8007c0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8007c3:	89 ca                	mov    %ecx,%edx
  8007c5:	8d 45 14             	lea    0x14(%ebp),%eax
  8007c8:	e8 59 fc ff ff       	call   800426 <getuint>
  8007cd:	89 c1                	mov    %eax,%ecx
  8007cf:	89 d3                	mov    %edx,%ebx
  8007d1:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  8007d6:	eb 62                	jmp    80083a <vprintfmt+0x3bd>
  8007d8:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  8007db:	89 ca                	mov    %ecx,%edx
  8007dd:	8d 45 14             	lea    0x14(%ebp),%eax
  8007e0:	e8 41 fc ff ff       	call   800426 <getuint>
  8007e5:	89 c1                	mov    %eax,%ecx
  8007e7:	89 d3                	mov    %edx,%ebx
  8007e9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  8007ee:	eb 4a                	jmp    80083a <vprintfmt+0x3bd>
  8007f0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  8007f3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007f7:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  8007fe:	ff d7                	call   *%edi
			putch('x', putdat);
  800800:	89 74 24 04          	mov    %esi,0x4(%esp)
  800804:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80080b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80080d:	8b 45 14             	mov    0x14(%ebp),%eax
  800810:	8d 50 04             	lea    0x4(%eax),%edx
  800813:	89 55 14             	mov    %edx,0x14(%ebp)
  800816:	8b 08                	mov    (%eax),%ecx
  800818:	bb 00 00 00 00       	mov    $0x0,%ebx
  80081d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800822:	eb 16                	jmp    80083a <vprintfmt+0x3bd>
  800824:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800827:	89 ca                	mov    %ecx,%edx
  800829:	8d 45 14             	lea    0x14(%ebp),%eax
  80082c:	e8 f5 fb ff ff       	call   800426 <getuint>
  800831:	89 c1                	mov    %eax,%ecx
  800833:	89 d3                	mov    %edx,%ebx
  800835:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80083a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80083e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800842:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800845:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800849:	89 44 24 08          	mov    %eax,0x8(%esp)
  80084d:	89 0c 24             	mov    %ecx,(%esp)
  800850:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800854:	89 f2                	mov    %esi,%edx
  800856:	89 f8                	mov    %edi,%eax
  800858:	e8 d3 fa ff ff       	call   800330 <printnum>
  80085d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800860:	e9 44 fc ff ff       	jmp    8004a9 <vprintfmt+0x2c>
  800865:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800868:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80086b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80086f:	89 14 24             	mov    %edx,(%esp)
  800872:	ff d7                	call   *%edi
  800874:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800877:	e9 2d fc ff ff       	jmp    8004a9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  80087c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800880:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800887:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800889:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80088c:	80 38 25             	cmpb   $0x25,(%eax)
  80088f:	0f 84 14 fc ff ff    	je     8004a9 <vprintfmt+0x2c>
  800895:	89 c3                	mov    %eax,%ebx
  800897:	eb f0                	jmp    800889 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800899:	83 c4 5c             	add    $0x5c,%esp
  80089c:	5b                   	pop    %ebx
  80089d:	5e                   	pop    %esi
  80089e:	5f                   	pop    %edi
  80089f:	5d                   	pop    %ebp
  8008a0:	c3                   	ret    

008008a1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8008a1:	55                   	push   %ebp
  8008a2:	89 e5                	mov    %esp,%ebp
  8008a4:	83 ec 28             	sub    $0x28,%esp
  8008a7:	8b 45 08             	mov    0x8(%ebp),%eax
  8008aa:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  8008ad:	85 c0                	test   %eax,%eax
  8008af:	74 04                	je     8008b5 <vsnprintf+0x14>
  8008b1:	85 d2                	test   %edx,%edx
  8008b3:	7f 07                	jg     8008bc <vsnprintf+0x1b>
  8008b5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8008ba:	eb 3b                	jmp    8008f7 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  8008bc:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8008bf:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8008c3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8008c6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8008cd:	8b 45 14             	mov    0x14(%ebp),%eax
  8008d0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8008d4:	8b 45 10             	mov    0x10(%ebp),%eax
  8008d7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8008db:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8008de:	89 44 24 04          	mov    %eax,0x4(%esp)
  8008e2:	c7 04 24 60 04 80 00 	movl   $0x800460,(%esp)
  8008e9:	e8 8f fb ff ff       	call   80047d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8008ee:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8008f1:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  8008f4:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  8008f7:	c9                   	leave  
  8008f8:	c3                   	ret    

008008f9 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  8008f9:	55                   	push   %ebp
  8008fa:	89 e5                	mov    %esp,%ebp
  8008fc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  8008ff:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800902:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800906:	8b 45 10             	mov    0x10(%ebp),%eax
  800909:	89 44 24 08          	mov    %eax,0x8(%esp)
  80090d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800910:	89 44 24 04          	mov    %eax,0x4(%esp)
  800914:	8b 45 08             	mov    0x8(%ebp),%eax
  800917:	89 04 24             	mov    %eax,(%esp)
  80091a:	e8 82 ff ff ff       	call   8008a1 <vsnprintf>
	va_end(ap);

	return rc;
}
  80091f:	c9                   	leave  
  800920:	c3                   	ret    

00800921 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800921:	55                   	push   %ebp
  800922:	89 e5                	mov    %esp,%ebp
  800924:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800927:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  80092a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80092e:	8b 45 10             	mov    0x10(%ebp),%eax
  800931:	89 44 24 08          	mov    %eax,0x8(%esp)
  800935:	8b 45 0c             	mov    0xc(%ebp),%eax
  800938:	89 44 24 04          	mov    %eax,0x4(%esp)
  80093c:	8b 45 08             	mov    0x8(%ebp),%eax
  80093f:	89 04 24             	mov    %eax,(%esp)
  800942:	e8 36 fb ff ff       	call   80047d <vprintfmt>
	va_end(ap);
}
  800947:	c9                   	leave  
  800948:	c3                   	ret    
  800949:	00 00                	add    %al,(%eax)
  80094b:	00 00                	add    %al,(%eax)
  80094d:	00 00                	add    %al,(%eax)
	...

00800950 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800950:	55                   	push   %ebp
  800951:	89 e5                	mov    %esp,%ebp
  800953:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800956:	b8 00 00 00 00       	mov    $0x0,%eax
  80095b:	80 3a 00             	cmpb   $0x0,(%edx)
  80095e:	74 09                	je     800969 <strlen+0x19>
		n++;
  800960:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800963:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800967:	75 f7                	jne    800960 <strlen+0x10>
		n++;
	return n;
}
  800969:	5d                   	pop    %ebp
  80096a:	c3                   	ret    

0080096b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80096b:	55                   	push   %ebp
  80096c:	89 e5                	mov    %esp,%ebp
  80096e:	53                   	push   %ebx
  80096f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800972:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800975:	85 c9                	test   %ecx,%ecx
  800977:	74 19                	je     800992 <strnlen+0x27>
  800979:	80 3b 00             	cmpb   $0x0,(%ebx)
  80097c:	74 14                	je     800992 <strnlen+0x27>
  80097e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800983:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800986:	39 c8                	cmp    %ecx,%eax
  800988:	74 0d                	je     800997 <strnlen+0x2c>
  80098a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  80098e:	75 f3                	jne    800983 <strnlen+0x18>
  800990:	eb 05                	jmp    800997 <strnlen+0x2c>
  800992:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800997:	5b                   	pop    %ebx
  800998:	5d                   	pop    %ebp
  800999:	c3                   	ret    

0080099a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  80099a:	55                   	push   %ebp
  80099b:	89 e5                	mov    %esp,%ebp
  80099d:	53                   	push   %ebx
  80099e:	8b 45 08             	mov    0x8(%ebp),%eax
  8009a1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8009a4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  8009a9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  8009ad:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  8009b0:	83 c2 01             	add    $0x1,%edx
  8009b3:	84 c9                	test   %cl,%cl
  8009b5:	75 f2                	jne    8009a9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  8009b7:	5b                   	pop    %ebx
  8009b8:	5d                   	pop    %ebp
  8009b9:	c3                   	ret    

008009ba <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8009ba:	55                   	push   %ebp
  8009bb:	89 e5                	mov    %esp,%ebp
  8009bd:	56                   	push   %esi
  8009be:	53                   	push   %ebx
  8009bf:	8b 45 08             	mov    0x8(%ebp),%eax
  8009c2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009c5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8009c8:	85 f6                	test   %esi,%esi
  8009ca:	74 18                	je     8009e4 <strncpy+0x2a>
  8009cc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  8009d1:	0f b6 1a             	movzbl (%edx),%ebx
  8009d4:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  8009d7:	80 3a 01             	cmpb   $0x1,(%edx)
  8009da:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8009dd:	83 c1 01             	add    $0x1,%ecx
  8009e0:	39 ce                	cmp    %ecx,%esi
  8009e2:	77 ed                	ja     8009d1 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  8009e4:	5b                   	pop    %ebx
  8009e5:	5e                   	pop    %esi
  8009e6:	5d                   	pop    %ebp
  8009e7:	c3                   	ret    

008009e8 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  8009e8:	55                   	push   %ebp
  8009e9:	89 e5                	mov    %esp,%ebp
  8009eb:	56                   	push   %esi
  8009ec:	53                   	push   %ebx
  8009ed:	8b 75 08             	mov    0x8(%ebp),%esi
  8009f0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009f3:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  8009f6:	89 f0                	mov    %esi,%eax
  8009f8:	85 c9                	test   %ecx,%ecx
  8009fa:	74 27                	je     800a23 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  8009fc:	83 e9 01             	sub    $0x1,%ecx
  8009ff:	74 1d                	je     800a1e <strlcpy+0x36>
  800a01:	0f b6 1a             	movzbl (%edx),%ebx
  800a04:	84 db                	test   %bl,%bl
  800a06:	74 16                	je     800a1e <strlcpy+0x36>
			*dst++ = *src++;
  800a08:	88 18                	mov    %bl,(%eax)
  800a0a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800a0d:	83 e9 01             	sub    $0x1,%ecx
  800a10:	74 0e                	je     800a20 <strlcpy+0x38>
			*dst++ = *src++;
  800a12:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800a15:	0f b6 1a             	movzbl (%edx),%ebx
  800a18:	84 db                	test   %bl,%bl
  800a1a:	75 ec                	jne    800a08 <strlcpy+0x20>
  800a1c:	eb 02                	jmp    800a20 <strlcpy+0x38>
  800a1e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800a20:	c6 00 00             	movb   $0x0,(%eax)
  800a23:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800a25:	5b                   	pop    %ebx
  800a26:	5e                   	pop    %esi
  800a27:	5d                   	pop    %ebp
  800a28:	c3                   	ret    

00800a29 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800a29:	55                   	push   %ebp
  800a2a:	89 e5                	mov    %esp,%ebp
  800a2c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800a2f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800a32:	0f b6 01             	movzbl (%ecx),%eax
  800a35:	84 c0                	test   %al,%al
  800a37:	74 15                	je     800a4e <strcmp+0x25>
  800a39:	3a 02                	cmp    (%edx),%al
  800a3b:	75 11                	jne    800a4e <strcmp+0x25>
		p++, q++;
  800a3d:	83 c1 01             	add    $0x1,%ecx
  800a40:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800a43:	0f b6 01             	movzbl (%ecx),%eax
  800a46:	84 c0                	test   %al,%al
  800a48:	74 04                	je     800a4e <strcmp+0x25>
  800a4a:	3a 02                	cmp    (%edx),%al
  800a4c:	74 ef                	je     800a3d <strcmp+0x14>
  800a4e:	0f b6 c0             	movzbl %al,%eax
  800a51:	0f b6 12             	movzbl (%edx),%edx
  800a54:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800a56:	5d                   	pop    %ebp
  800a57:	c3                   	ret    

00800a58 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800a58:	55                   	push   %ebp
  800a59:	89 e5                	mov    %esp,%ebp
  800a5b:	53                   	push   %ebx
  800a5c:	8b 55 08             	mov    0x8(%ebp),%edx
  800a5f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800a62:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800a65:	85 c0                	test   %eax,%eax
  800a67:	74 23                	je     800a8c <strncmp+0x34>
  800a69:	0f b6 1a             	movzbl (%edx),%ebx
  800a6c:	84 db                	test   %bl,%bl
  800a6e:	74 24                	je     800a94 <strncmp+0x3c>
  800a70:	3a 19                	cmp    (%ecx),%bl
  800a72:	75 20                	jne    800a94 <strncmp+0x3c>
  800a74:	83 e8 01             	sub    $0x1,%eax
  800a77:	74 13                	je     800a8c <strncmp+0x34>
		n--, p++, q++;
  800a79:	83 c2 01             	add    $0x1,%edx
  800a7c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800a7f:	0f b6 1a             	movzbl (%edx),%ebx
  800a82:	84 db                	test   %bl,%bl
  800a84:	74 0e                	je     800a94 <strncmp+0x3c>
  800a86:	3a 19                	cmp    (%ecx),%bl
  800a88:	74 ea                	je     800a74 <strncmp+0x1c>
  800a8a:	eb 08                	jmp    800a94 <strncmp+0x3c>
  800a8c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800a91:	5b                   	pop    %ebx
  800a92:	5d                   	pop    %ebp
  800a93:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800a94:	0f b6 02             	movzbl (%edx),%eax
  800a97:	0f b6 11             	movzbl (%ecx),%edx
  800a9a:	29 d0                	sub    %edx,%eax
  800a9c:	eb f3                	jmp    800a91 <strncmp+0x39>

00800a9e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800a9e:	55                   	push   %ebp
  800a9f:	89 e5                	mov    %esp,%ebp
  800aa1:	8b 45 08             	mov    0x8(%ebp),%eax
  800aa4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800aa8:	0f b6 10             	movzbl (%eax),%edx
  800aab:	84 d2                	test   %dl,%dl
  800aad:	74 15                	je     800ac4 <strchr+0x26>
		if (*s == c)
  800aaf:	38 ca                	cmp    %cl,%dl
  800ab1:	75 07                	jne    800aba <strchr+0x1c>
  800ab3:	eb 14                	jmp    800ac9 <strchr+0x2b>
  800ab5:	38 ca                	cmp    %cl,%dl
  800ab7:	90                   	nop
  800ab8:	74 0f                	je     800ac9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800aba:	83 c0 01             	add    $0x1,%eax
  800abd:	0f b6 10             	movzbl (%eax),%edx
  800ac0:	84 d2                	test   %dl,%dl
  800ac2:	75 f1                	jne    800ab5 <strchr+0x17>
  800ac4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800ac9:	5d                   	pop    %ebp
  800aca:	c3                   	ret    

00800acb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800acb:	55                   	push   %ebp
  800acc:	89 e5                	mov    %esp,%ebp
  800ace:	8b 45 08             	mov    0x8(%ebp),%eax
  800ad1:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800ad5:	0f b6 10             	movzbl (%eax),%edx
  800ad8:	84 d2                	test   %dl,%dl
  800ada:	74 18                	je     800af4 <strfind+0x29>
		if (*s == c)
  800adc:	38 ca                	cmp    %cl,%dl
  800ade:	75 0a                	jne    800aea <strfind+0x1f>
  800ae0:	eb 12                	jmp    800af4 <strfind+0x29>
  800ae2:	38 ca                	cmp    %cl,%dl
  800ae4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800ae8:	74 0a                	je     800af4 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800aea:	83 c0 01             	add    $0x1,%eax
  800aed:	0f b6 10             	movzbl (%eax),%edx
  800af0:	84 d2                	test   %dl,%dl
  800af2:	75 ee                	jne    800ae2 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800af4:	5d                   	pop    %ebp
  800af5:	c3                   	ret    

00800af6 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800af6:	55                   	push   %ebp
  800af7:	89 e5                	mov    %esp,%ebp
  800af9:	83 ec 0c             	sub    $0xc,%esp
  800afc:	89 1c 24             	mov    %ebx,(%esp)
  800aff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800b03:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800b07:	8b 7d 08             	mov    0x8(%ebp),%edi
  800b0a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b0d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800b10:	85 c9                	test   %ecx,%ecx
  800b12:	74 30                	je     800b44 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b14:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b1a:	75 25                	jne    800b41 <memset+0x4b>
  800b1c:	f6 c1 03             	test   $0x3,%cl
  800b1f:	75 20                	jne    800b41 <memset+0x4b>
		c &= 0xFF;
  800b21:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800b24:	89 d3                	mov    %edx,%ebx
  800b26:	c1 e3 08             	shl    $0x8,%ebx
  800b29:	89 d6                	mov    %edx,%esi
  800b2b:	c1 e6 18             	shl    $0x18,%esi
  800b2e:	89 d0                	mov    %edx,%eax
  800b30:	c1 e0 10             	shl    $0x10,%eax
  800b33:	09 f0                	or     %esi,%eax
  800b35:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800b37:	09 d8                	or     %ebx,%eax
  800b39:	c1 e9 02             	shr    $0x2,%ecx
  800b3c:	fc                   	cld    
  800b3d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b3f:	eb 03                	jmp    800b44 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800b41:	fc                   	cld    
  800b42:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800b44:	89 f8                	mov    %edi,%eax
  800b46:	8b 1c 24             	mov    (%esp),%ebx
  800b49:	8b 74 24 04          	mov    0x4(%esp),%esi
  800b4d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800b51:	89 ec                	mov    %ebp,%esp
  800b53:	5d                   	pop    %ebp
  800b54:	c3                   	ret    

00800b55 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800b55:	55                   	push   %ebp
  800b56:	89 e5                	mov    %esp,%ebp
  800b58:	83 ec 08             	sub    $0x8,%esp
  800b5b:	89 34 24             	mov    %esi,(%esp)
  800b5e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800b62:	8b 45 08             	mov    0x8(%ebp),%eax
  800b65:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800b68:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800b6b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800b6d:	39 c6                	cmp    %eax,%esi
  800b6f:	73 35                	jae    800ba6 <memmove+0x51>
  800b71:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800b74:	39 d0                	cmp    %edx,%eax
  800b76:	73 2e                	jae    800ba6 <memmove+0x51>
		s += n;
		d += n;
  800b78:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b7a:	f6 c2 03             	test   $0x3,%dl
  800b7d:	75 1b                	jne    800b9a <memmove+0x45>
  800b7f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b85:	75 13                	jne    800b9a <memmove+0x45>
  800b87:	f6 c1 03             	test   $0x3,%cl
  800b8a:	75 0e                	jne    800b9a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800b8c:	83 ef 04             	sub    $0x4,%edi
  800b8f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800b92:	c1 e9 02             	shr    $0x2,%ecx
  800b95:	fd                   	std    
  800b96:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b98:	eb 09                	jmp    800ba3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800b9a:	83 ef 01             	sub    $0x1,%edi
  800b9d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800ba0:	fd                   	std    
  800ba1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800ba3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800ba4:	eb 20                	jmp    800bc6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800ba6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800bac:	75 15                	jne    800bc3 <memmove+0x6e>
  800bae:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800bb4:	75 0d                	jne    800bc3 <memmove+0x6e>
  800bb6:	f6 c1 03             	test   $0x3,%cl
  800bb9:	75 08                	jne    800bc3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800bbb:	c1 e9 02             	shr    $0x2,%ecx
  800bbe:	fc                   	cld    
  800bbf:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bc1:	eb 03                	jmp    800bc6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800bc3:	fc                   	cld    
  800bc4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800bc6:	8b 34 24             	mov    (%esp),%esi
  800bc9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800bcd:	89 ec                	mov    %ebp,%esp
  800bcf:	5d                   	pop    %ebp
  800bd0:	c3                   	ret    

00800bd1 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800bd1:	55                   	push   %ebp
  800bd2:	89 e5                	mov    %esp,%ebp
  800bd4:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800bd7:	8b 45 10             	mov    0x10(%ebp),%eax
  800bda:	89 44 24 08          	mov    %eax,0x8(%esp)
  800bde:	8b 45 0c             	mov    0xc(%ebp),%eax
  800be1:	89 44 24 04          	mov    %eax,0x4(%esp)
  800be5:	8b 45 08             	mov    0x8(%ebp),%eax
  800be8:	89 04 24             	mov    %eax,(%esp)
  800beb:	e8 65 ff ff ff       	call   800b55 <memmove>
}
  800bf0:	c9                   	leave  
  800bf1:	c3                   	ret    

00800bf2 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800bf2:	55                   	push   %ebp
  800bf3:	89 e5                	mov    %esp,%ebp
  800bf5:	57                   	push   %edi
  800bf6:	56                   	push   %esi
  800bf7:	53                   	push   %ebx
  800bf8:	8b 75 08             	mov    0x8(%ebp),%esi
  800bfb:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800bfe:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c01:	85 c9                	test   %ecx,%ecx
  800c03:	74 36                	je     800c3b <memcmp+0x49>
		if (*s1 != *s2)
  800c05:	0f b6 06             	movzbl (%esi),%eax
  800c08:	0f b6 1f             	movzbl (%edi),%ebx
  800c0b:	38 d8                	cmp    %bl,%al
  800c0d:	74 20                	je     800c2f <memcmp+0x3d>
  800c0f:	eb 14                	jmp    800c25 <memcmp+0x33>
  800c11:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800c16:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800c1b:	83 c2 01             	add    $0x1,%edx
  800c1e:	83 e9 01             	sub    $0x1,%ecx
  800c21:	38 d8                	cmp    %bl,%al
  800c23:	74 12                	je     800c37 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800c25:	0f b6 c0             	movzbl %al,%eax
  800c28:	0f b6 db             	movzbl %bl,%ebx
  800c2b:	29 d8                	sub    %ebx,%eax
  800c2d:	eb 11                	jmp    800c40 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c2f:	83 e9 01             	sub    $0x1,%ecx
  800c32:	ba 00 00 00 00       	mov    $0x0,%edx
  800c37:	85 c9                	test   %ecx,%ecx
  800c39:	75 d6                	jne    800c11 <memcmp+0x1f>
  800c3b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800c40:	5b                   	pop    %ebx
  800c41:	5e                   	pop    %esi
  800c42:	5f                   	pop    %edi
  800c43:	5d                   	pop    %ebp
  800c44:	c3                   	ret    

00800c45 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800c45:	55                   	push   %ebp
  800c46:	89 e5                	mov    %esp,%ebp
  800c48:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800c4b:	89 c2                	mov    %eax,%edx
  800c4d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800c50:	39 d0                	cmp    %edx,%eax
  800c52:	73 15                	jae    800c69 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800c54:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800c58:	38 08                	cmp    %cl,(%eax)
  800c5a:	75 06                	jne    800c62 <memfind+0x1d>
  800c5c:	eb 0b                	jmp    800c69 <memfind+0x24>
  800c5e:	38 08                	cmp    %cl,(%eax)
  800c60:	74 07                	je     800c69 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800c62:	83 c0 01             	add    $0x1,%eax
  800c65:	39 c2                	cmp    %eax,%edx
  800c67:	77 f5                	ja     800c5e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800c69:	5d                   	pop    %ebp
  800c6a:	c3                   	ret    

00800c6b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800c6b:	55                   	push   %ebp
  800c6c:	89 e5                	mov    %esp,%ebp
  800c6e:	57                   	push   %edi
  800c6f:	56                   	push   %esi
  800c70:	53                   	push   %ebx
  800c71:	83 ec 04             	sub    $0x4,%esp
  800c74:	8b 55 08             	mov    0x8(%ebp),%edx
  800c77:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800c7a:	0f b6 02             	movzbl (%edx),%eax
  800c7d:	3c 20                	cmp    $0x20,%al
  800c7f:	74 04                	je     800c85 <strtol+0x1a>
  800c81:	3c 09                	cmp    $0x9,%al
  800c83:	75 0e                	jne    800c93 <strtol+0x28>
		s++;
  800c85:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800c88:	0f b6 02             	movzbl (%edx),%eax
  800c8b:	3c 20                	cmp    $0x20,%al
  800c8d:	74 f6                	je     800c85 <strtol+0x1a>
  800c8f:	3c 09                	cmp    $0x9,%al
  800c91:	74 f2                	je     800c85 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800c93:	3c 2b                	cmp    $0x2b,%al
  800c95:	75 0c                	jne    800ca3 <strtol+0x38>
		s++;
  800c97:	83 c2 01             	add    $0x1,%edx
  800c9a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800ca1:	eb 15                	jmp    800cb8 <strtol+0x4d>
	else if (*s == '-')
  800ca3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800caa:	3c 2d                	cmp    $0x2d,%al
  800cac:	75 0a                	jne    800cb8 <strtol+0x4d>
		s++, neg = 1;
  800cae:	83 c2 01             	add    $0x1,%edx
  800cb1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800cb8:	85 db                	test   %ebx,%ebx
  800cba:	0f 94 c0             	sete   %al
  800cbd:	74 05                	je     800cc4 <strtol+0x59>
  800cbf:	83 fb 10             	cmp    $0x10,%ebx
  800cc2:	75 18                	jne    800cdc <strtol+0x71>
  800cc4:	80 3a 30             	cmpb   $0x30,(%edx)
  800cc7:	75 13                	jne    800cdc <strtol+0x71>
  800cc9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800ccd:	8d 76 00             	lea    0x0(%esi),%esi
  800cd0:	75 0a                	jne    800cdc <strtol+0x71>
		s += 2, base = 16;
  800cd2:	83 c2 02             	add    $0x2,%edx
  800cd5:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800cda:	eb 15                	jmp    800cf1 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800cdc:	84 c0                	test   %al,%al
  800cde:	66 90                	xchg   %ax,%ax
  800ce0:	74 0f                	je     800cf1 <strtol+0x86>
  800ce2:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800ce7:	80 3a 30             	cmpb   $0x30,(%edx)
  800cea:	75 05                	jne    800cf1 <strtol+0x86>
		s++, base = 8;
  800cec:	83 c2 01             	add    $0x1,%edx
  800cef:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800cf1:	b8 00 00 00 00       	mov    $0x0,%eax
  800cf6:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800cf8:	0f b6 0a             	movzbl (%edx),%ecx
  800cfb:	89 cf                	mov    %ecx,%edi
  800cfd:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800d00:	80 fb 09             	cmp    $0x9,%bl
  800d03:	77 08                	ja     800d0d <strtol+0xa2>
			dig = *s - '0';
  800d05:	0f be c9             	movsbl %cl,%ecx
  800d08:	83 e9 30             	sub    $0x30,%ecx
  800d0b:	eb 1e                	jmp    800d2b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800d0d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800d10:	80 fb 19             	cmp    $0x19,%bl
  800d13:	77 08                	ja     800d1d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800d15:	0f be c9             	movsbl %cl,%ecx
  800d18:	83 e9 57             	sub    $0x57,%ecx
  800d1b:	eb 0e                	jmp    800d2b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800d1d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800d20:	80 fb 19             	cmp    $0x19,%bl
  800d23:	77 15                	ja     800d3a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800d25:	0f be c9             	movsbl %cl,%ecx
  800d28:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800d2b:	39 f1                	cmp    %esi,%ecx
  800d2d:	7d 0b                	jge    800d3a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800d2f:	83 c2 01             	add    $0x1,%edx
  800d32:	0f af c6             	imul   %esi,%eax
  800d35:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800d38:	eb be                	jmp    800cf8 <strtol+0x8d>
  800d3a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800d3c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800d40:	74 05                	je     800d47 <strtol+0xdc>
		*endptr = (char *) s;
  800d42:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800d45:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800d47:	89 ca                	mov    %ecx,%edx
  800d49:	f7 da                	neg    %edx
  800d4b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800d4f:	0f 45 c2             	cmovne %edx,%eax
}
  800d52:	83 c4 04             	add    $0x4,%esp
  800d55:	5b                   	pop    %ebx
  800d56:	5e                   	pop    %esi
  800d57:	5f                   	pop    %edi
  800d58:	5d                   	pop    %ebp
  800d59:	c3                   	ret    
	...

00800d5c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800d5c:	55                   	push   %ebp
  800d5d:	89 e5                	mov    %esp,%ebp
  800d5f:	83 ec 0c             	sub    $0xc,%esp
  800d62:	89 1c 24             	mov    %ebx,(%esp)
  800d65:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d69:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d6d:	ba 00 00 00 00       	mov    $0x0,%edx
  800d72:	b8 01 00 00 00       	mov    $0x1,%eax
  800d77:	89 d1                	mov    %edx,%ecx
  800d79:	89 d3                	mov    %edx,%ebx
  800d7b:	89 d7                	mov    %edx,%edi
  800d7d:	89 d6                	mov    %edx,%esi
  800d7f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800d81:	8b 1c 24             	mov    (%esp),%ebx
  800d84:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d88:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d8c:	89 ec                	mov    %ebp,%esp
  800d8e:	5d                   	pop    %ebp
  800d8f:	c3                   	ret    

00800d90 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800d90:	55                   	push   %ebp
  800d91:	89 e5                	mov    %esp,%ebp
  800d93:	83 ec 0c             	sub    $0xc,%esp
  800d96:	89 1c 24             	mov    %ebx,(%esp)
  800d99:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d9d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800da1:	b8 00 00 00 00       	mov    $0x0,%eax
  800da6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800da9:	8b 55 08             	mov    0x8(%ebp),%edx
  800dac:	89 c3                	mov    %eax,%ebx
  800dae:	89 c7                	mov    %eax,%edi
  800db0:	89 c6                	mov    %eax,%esi
  800db2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800db4:	8b 1c 24             	mov    (%esp),%ebx
  800db7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800dbb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800dbf:	89 ec                	mov    %ebp,%esp
  800dc1:	5d                   	pop    %ebp
  800dc2:	c3                   	ret    

00800dc3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800dc3:	55                   	push   %ebp
  800dc4:	89 e5                	mov    %esp,%ebp
  800dc6:	83 ec 0c             	sub    $0xc,%esp
  800dc9:	89 1c 24             	mov    %ebx,(%esp)
  800dcc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800dd0:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800dd4:	bb 00 00 00 00       	mov    $0x0,%ebx
  800dd9:	b8 10 00 00 00       	mov    $0x10,%eax
  800dde:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800de1:	8b 55 08             	mov    0x8(%ebp),%edx
  800de4:	89 df                	mov    %ebx,%edi
  800de6:	89 de                	mov    %ebx,%esi
  800de8:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800dea:	8b 1c 24             	mov    (%esp),%ebx
  800ded:	8b 74 24 04          	mov    0x4(%esp),%esi
  800df1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800df5:	89 ec                	mov    %ebp,%esp
  800df7:	5d                   	pop    %ebp
  800df8:	c3                   	ret    

00800df9 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800df9:	55                   	push   %ebp
  800dfa:	89 e5                	mov    %esp,%ebp
  800dfc:	83 ec 0c             	sub    $0xc,%esp
  800dff:	89 1c 24             	mov    %ebx,(%esp)
  800e02:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e06:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e0a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e0f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800e14:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e17:	8b 55 08             	mov    0x8(%ebp),%edx
  800e1a:	89 df                	mov    %ebx,%edi
  800e1c:	89 de                	mov    %ebx,%esi
  800e1e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800e20:	8b 1c 24             	mov    (%esp),%ebx
  800e23:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e27:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e2b:	89 ec                	mov    %ebp,%esp
  800e2d:	5d                   	pop    %ebp
  800e2e:	c3                   	ret    

00800e2f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800e2f:	55                   	push   %ebp
  800e30:	89 e5                	mov    %esp,%ebp
  800e32:	83 ec 0c             	sub    $0xc,%esp
  800e35:	89 1c 24             	mov    %ebx,(%esp)
  800e38:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e3c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e40:	ba 00 00 00 00       	mov    $0x0,%edx
  800e45:	b8 0e 00 00 00       	mov    $0xe,%eax
  800e4a:	89 d1                	mov    %edx,%ecx
  800e4c:	89 d3                	mov    %edx,%ebx
  800e4e:	89 d7                	mov    %edx,%edi
  800e50:	89 d6                	mov    %edx,%esi
  800e52:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800e54:	8b 1c 24             	mov    (%esp),%ebx
  800e57:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e5b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e5f:	89 ec                	mov    %ebp,%esp
  800e61:	5d                   	pop    %ebp
  800e62:	c3                   	ret    

00800e63 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800e63:	55                   	push   %ebp
  800e64:	89 e5                	mov    %esp,%ebp
  800e66:	83 ec 38             	sub    $0x38,%esp
  800e69:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e6c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e6f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e72:	b9 00 00 00 00       	mov    $0x0,%ecx
  800e77:	b8 0d 00 00 00       	mov    $0xd,%eax
  800e7c:	8b 55 08             	mov    0x8(%ebp),%edx
  800e7f:	89 cb                	mov    %ecx,%ebx
  800e81:	89 cf                	mov    %ecx,%edi
  800e83:	89 ce                	mov    %ecx,%esi
  800e85:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800e87:	85 c0                	test   %eax,%eax
  800e89:	7e 28                	jle    800eb3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800e8b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800e8f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800e96:	00 
  800e97:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800e9e:	00 
  800e9f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ea6:	00 
  800ea7:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  800eae:	e8 51 f3 ff ff       	call   800204 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800eb3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800eb6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800eb9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800ebc:	89 ec                	mov    %ebp,%esp
  800ebe:	5d                   	pop    %ebp
  800ebf:	c3                   	ret    

00800ec0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800ec0:	55                   	push   %ebp
  800ec1:	89 e5                	mov    %esp,%ebp
  800ec3:	83 ec 38             	sub    $0x38,%esp
  800ec6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ec9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800ecc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ecf:	be 00 00 00 00       	mov    $0x0,%esi
  800ed4:	b8 0c 00 00 00       	mov    $0xc,%eax
  800ed9:	8b 7d 14             	mov    0x14(%ebp),%edi
  800edc:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800edf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ee2:	8b 55 08             	mov    0x8(%ebp),%edx
  800ee5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800ee7:	85 c0                	test   %eax,%eax
  800ee9:	7e 28                	jle    800f13 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  800eeb:	89 44 24 10          	mov    %eax,0x10(%esp)
  800eef:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800ef6:	00 
  800ef7:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800efe:	00 
  800eff:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f06:	00 
  800f07:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  800f0e:	e8 f1 f2 ff ff       	call   800204 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800f13:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f16:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f19:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f1c:	89 ec                	mov    %ebp,%esp
  800f1e:	5d                   	pop    %ebp
  800f1f:	c3                   	ret    

00800f20 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800f20:	55                   	push   %ebp
  800f21:	89 e5                	mov    %esp,%ebp
  800f23:	83 ec 38             	sub    $0x38,%esp
  800f26:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f29:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f2c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f2f:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f34:	b8 0a 00 00 00       	mov    $0xa,%eax
  800f39:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f3c:	8b 55 08             	mov    0x8(%ebp),%edx
  800f3f:	89 df                	mov    %ebx,%edi
  800f41:	89 de                	mov    %ebx,%esi
  800f43:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f45:	85 c0                	test   %eax,%eax
  800f47:	7e 28                	jle    800f71 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f49:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f4d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800f54:	00 
  800f55:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800f5c:	00 
  800f5d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f64:	00 
  800f65:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  800f6c:	e8 93 f2 ff ff       	call   800204 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800f71:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f74:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f77:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f7a:	89 ec                	mov    %ebp,%esp
  800f7c:	5d                   	pop    %ebp
  800f7d:	c3                   	ret    

00800f7e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800f7e:	55                   	push   %ebp
  800f7f:	89 e5                	mov    %esp,%ebp
  800f81:	83 ec 38             	sub    $0x38,%esp
  800f84:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f87:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f8a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f8d:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f92:	b8 09 00 00 00       	mov    $0x9,%eax
  800f97:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f9a:	8b 55 08             	mov    0x8(%ebp),%edx
  800f9d:	89 df                	mov    %ebx,%edi
  800f9f:	89 de                	mov    %ebx,%esi
  800fa1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fa3:	85 c0                	test   %eax,%eax
  800fa5:	7e 28                	jle    800fcf <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fa7:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fab:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  800fb2:	00 
  800fb3:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800fba:	00 
  800fbb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800fc2:	00 
  800fc3:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  800fca:	e8 35 f2 ff ff       	call   800204 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800fcf:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800fd2:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800fd5:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800fd8:	89 ec                	mov    %ebp,%esp
  800fda:	5d                   	pop    %ebp
  800fdb:	c3                   	ret    

00800fdc <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  800fdc:	55                   	push   %ebp
  800fdd:	89 e5                	mov    %esp,%ebp
  800fdf:	83 ec 38             	sub    $0x38,%esp
  800fe2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fe5:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fe8:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800feb:	bb 00 00 00 00       	mov    $0x0,%ebx
  800ff0:	b8 08 00 00 00       	mov    $0x8,%eax
  800ff5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ff8:	8b 55 08             	mov    0x8(%ebp),%edx
  800ffb:	89 df                	mov    %ebx,%edi
  800ffd:	89 de                	mov    %ebx,%esi
  800fff:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801001:	85 c0                	test   %eax,%eax
  801003:	7e 28                	jle    80102d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801005:	89 44 24 10          	mov    %eax,0x10(%esp)
  801009:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801010:	00 
  801011:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  801018:	00 
  801019:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801020:	00 
  801021:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  801028:	e8 d7 f1 ff ff       	call   800204 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80102d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801030:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801033:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801036:	89 ec                	mov    %ebp,%esp
  801038:	5d                   	pop    %ebp
  801039:	c3                   	ret    

0080103a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80103a:	55                   	push   %ebp
  80103b:	89 e5                	mov    %esp,%ebp
  80103d:	83 ec 38             	sub    $0x38,%esp
  801040:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801043:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801046:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801049:	bb 00 00 00 00       	mov    $0x0,%ebx
  80104e:	b8 06 00 00 00       	mov    $0x6,%eax
  801053:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801056:	8b 55 08             	mov    0x8(%ebp),%edx
  801059:	89 df                	mov    %ebx,%edi
  80105b:	89 de                	mov    %ebx,%esi
  80105d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80105f:	85 c0                	test   %eax,%eax
  801061:	7e 28                	jle    80108b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801063:	89 44 24 10          	mov    %eax,0x10(%esp)
  801067:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80106e:	00 
  80106f:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  801076:	00 
  801077:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80107e:	00 
  80107f:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  801086:	e8 79 f1 ff ff       	call   800204 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80108b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80108e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801091:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801094:	89 ec                	mov    %ebp,%esp
  801096:	5d                   	pop    %ebp
  801097:	c3                   	ret    

00801098 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801098:	55                   	push   %ebp
  801099:	89 e5                	mov    %esp,%ebp
  80109b:	83 ec 38             	sub    $0x38,%esp
  80109e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010a1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010a4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010a7:	b8 05 00 00 00       	mov    $0x5,%eax
  8010ac:	8b 75 18             	mov    0x18(%ebp),%esi
  8010af:	8b 7d 14             	mov    0x14(%ebp),%edi
  8010b2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8010b5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010b8:	8b 55 08             	mov    0x8(%ebp),%edx
  8010bb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010bd:	85 c0                	test   %eax,%eax
  8010bf:	7e 28                	jle    8010e9 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010c1:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010c5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  8010cc:	00 
  8010cd:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  8010d4:	00 
  8010d5:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010dc:	00 
  8010dd:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  8010e4:	e8 1b f1 ff ff       	call   800204 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  8010e9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010ec:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010ef:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010f2:	89 ec                	mov    %ebp,%esp
  8010f4:	5d                   	pop    %ebp
  8010f5:	c3                   	ret    

008010f6 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  8010f6:	55                   	push   %ebp
  8010f7:	89 e5                	mov    %esp,%ebp
  8010f9:	83 ec 38             	sub    $0x38,%esp
  8010fc:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010ff:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801102:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801105:	be 00 00 00 00       	mov    $0x0,%esi
  80110a:	b8 04 00 00 00       	mov    $0x4,%eax
  80110f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801112:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801115:	8b 55 08             	mov    0x8(%ebp),%edx
  801118:	89 f7                	mov    %esi,%edi
  80111a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80111c:	85 c0                	test   %eax,%eax
  80111e:	7e 28                	jle    801148 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801120:	89 44 24 10          	mov    %eax,0x10(%esp)
  801124:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80112b:	00 
  80112c:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  801133:	00 
  801134:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80113b:	00 
  80113c:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  801143:	e8 bc f0 ff ff       	call   800204 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801148:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80114b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80114e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801151:	89 ec                	mov    %ebp,%esp
  801153:	5d                   	pop    %ebp
  801154:	c3                   	ret    

00801155 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801155:	55                   	push   %ebp
  801156:	89 e5                	mov    %esp,%ebp
  801158:	83 ec 0c             	sub    $0xc,%esp
  80115b:	89 1c 24             	mov    %ebx,(%esp)
  80115e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801162:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801166:	ba 00 00 00 00       	mov    $0x0,%edx
  80116b:	b8 0b 00 00 00       	mov    $0xb,%eax
  801170:	89 d1                	mov    %edx,%ecx
  801172:	89 d3                	mov    %edx,%ebx
  801174:	89 d7                	mov    %edx,%edi
  801176:	89 d6                	mov    %edx,%esi
  801178:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80117a:	8b 1c 24             	mov    (%esp),%ebx
  80117d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801181:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801185:	89 ec                	mov    %ebp,%esp
  801187:	5d                   	pop    %ebp
  801188:	c3                   	ret    

00801189 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801189:	55                   	push   %ebp
  80118a:	89 e5                	mov    %esp,%ebp
  80118c:	83 ec 0c             	sub    $0xc,%esp
  80118f:	89 1c 24             	mov    %ebx,(%esp)
  801192:	89 74 24 04          	mov    %esi,0x4(%esp)
  801196:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80119a:	ba 00 00 00 00       	mov    $0x0,%edx
  80119f:	b8 02 00 00 00       	mov    $0x2,%eax
  8011a4:	89 d1                	mov    %edx,%ecx
  8011a6:	89 d3                	mov    %edx,%ebx
  8011a8:	89 d7                	mov    %edx,%edi
  8011aa:	89 d6                	mov    %edx,%esi
  8011ac:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8011ae:	8b 1c 24             	mov    (%esp),%ebx
  8011b1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8011b5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8011b9:	89 ec                	mov    %ebp,%esp
  8011bb:	5d                   	pop    %ebp
  8011bc:	c3                   	ret    

008011bd <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8011bd:	55                   	push   %ebp
  8011be:	89 e5                	mov    %esp,%ebp
  8011c0:	83 ec 38             	sub    $0x38,%esp
  8011c3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011c6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011c9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011cc:	b9 00 00 00 00       	mov    $0x0,%ecx
  8011d1:	b8 03 00 00 00       	mov    $0x3,%eax
  8011d6:	8b 55 08             	mov    0x8(%ebp),%edx
  8011d9:	89 cb                	mov    %ecx,%ebx
  8011db:	89 cf                	mov    %ecx,%edi
  8011dd:	89 ce                	mov    %ecx,%esi
  8011df:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011e1:	85 c0                	test   %eax,%eax
  8011e3:	7e 28                	jle    80120d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011e5:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011e9:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  8011f0:	00 
  8011f1:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  8011f8:	00 
  8011f9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801200:	00 
  801201:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  801208:	e8 f7 ef ff ff       	call   800204 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80120d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801210:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801213:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801216:	89 ec                	mov    %ebp,%esp
  801218:	5d                   	pop    %ebp
  801219:	c3                   	ret    
  80121a:	00 00                	add    %al,(%eax)
  80121c:	00 00                	add    %al,(%eax)
	...

00801220 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801220:	55                   	push   %ebp
  801221:	89 e5                	mov    %esp,%ebp
  801223:	8b 45 08             	mov    0x8(%ebp),%eax
  801226:	05 00 00 00 30       	add    $0x30000000,%eax
  80122b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80122e:	5d                   	pop    %ebp
  80122f:	c3                   	ret    

00801230 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801230:	55                   	push   %ebp
  801231:	89 e5                	mov    %esp,%ebp
  801233:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801236:	8b 45 08             	mov    0x8(%ebp),%eax
  801239:	89 04 24             	mov    %eax,(%esp)
  80123c:	e8 df ff ff ff       	call   801220 <fd2num>
  801241:	05 20 00 0d 00       	add    $0xd0020,%eax
  801246:	c1 e0 0c             	shl    $0xc,%eax
}
  801249:	c9                   	leave  
  80124a:	c3                   	ret    

0080124b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80124b:	55                   	push   %ebp
  80124c:	89 e5                	mov    %esp,%ebp
  80124e:	57                   	push   %edi
  80124f:	56                   	push   %esi
  801250:	53                   	push   %ebx
  801251:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801254:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801259:	a8 01                	test   $0x1,%al
  80125b:	74 36                	je     801293 <fd_alloc+0x48>
  80125d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801262:	a8 01                	test   $0x1,%al
  801264:	74 2d                	je     801293 <fd_alloc+0x48>
  801266:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80126b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  801270:	be 00 00 40 ef       	mov    $0xef400000,%esi
  801275:	89 c3                	mov    %eax,%ebx
  801277:	89 c2                	mov    %eax,%edx
  801279:	c1 ea 16             	shr    $0x16,%edx
  80127c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  80127f:	f6 c2 01             	test   $0x1,%dl
  801282:	74 14                	je     801298 <fd_alloc+0x4d>
  801284:	89 c2                	mov    %eax,%edx
  801286:	c1 ea 0c             	shr    $0xc,%edx
  801289:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80128c:	f6 c2 01             	test   $0x1,%dl
  80128f:	75 10                	jne    8012a1 <fd_alloc+0x56>
  801291:	eb 05                	jmp    801298 <fd_alloc+0x4d>
  801293:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801298:	89 1f                	mov    %ebx,(%edi)
  80129a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80129f:	eb 17                	jmp    8012b8 <fd_alloc+0x6d>
  8012a1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  8012a6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8012ab:	75 c8                	jne    801275 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8012ad:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  8012b3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  8012b8:	5b                   	pop    %ebx
  8012b9:	5e                   	pop    %esi
  8012ba:	5f                   	pop    %edi
  8012bb:	5d                   	pop    %ebp
  8012bc:	c3                   	ret    

008012bd <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8012bd:	55                   	push   %ebp
  8012be:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8012c0:	8b 45 08             	mov    0x8(%ebp),%eax
  8012c3:	83 f8 1f             	cmp    $0x1f,%eax
  8012c6:	77 36                	ja     8012fe <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8012c8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8012cd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  8012d0:	89 c2                	mov    %eax,%edx
  8012d2:	c1 ea 16             	shr    $0x16,%edx
  8012d5:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8012dc:	f6 c2 01             	test   $0x1,%dl
  8012df:	74 1d                	je     8012fe <fd_lookup+0x41>
  8012e1:	89 c2                	mov    %eax,%edx
  8012e3:	c1 ea 0c             	shr    $0xc,%edx
  8012e6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8012ed:	f6 c2 01             	test   $0x1,%dl
  8012f0:	74 0c                	je     8012fe <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  8012f2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8012f5:	89 02                	mov    %eax,(%edx)
  8012f7:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  8012fc:	eb 05                	jmp    801303 <fd_lookup+0x46>
  8012fe:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801303:	5d                   	pop    %ebp
  801304:	c3                   	ret    

00801305 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801305:	55                   	push   %ebp
  801306:	89 e5                	mov    %esp,%ebp
  801308:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80130b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80130e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801312:	8b 45 08             	mov    0x8(%ebp),%eax
  801315:	89 04 24             	mov    %eax,(%esp)
  801318:	e8 a0 ff ff ff       	call   8012bd <fd_lookup>
  80131d:	85 c0                	test   %eax,%eax
  80131f:	78 0e                	js     80132f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801321:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801324:	8b 55 0c             	mov    0xc(%ebp),%edx
  801327:	89 50 04             	mov    %edx,0x4(%eax)
  80132a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80132f:	c9                   	leave  
  801330:	c3                   	ret    

00801331 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801331:	55                   	push   %ebp
  801332:	89 e5                	mov    %esp,%ebp
  801334:	56                   	push   %esi
  801335:	53                   	push   %ebx
  801336:	83 ec 10             	sub    $0x10,%esp
  801339:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80133c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80133f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801344:	b8 04 60 80 00       	mov    $0x806004,%eax
  801349:	39 0d 04 60 80 00    	cmp    %ecx,0x806004
  80134f:	75 11                	jne    801362 <dev_lookup+0x31>
  801351:	eb 04                	jmp    801357 <dev_lookup+0x26>
  801353:	39 08                	cmp    %ecx,(%eax)
  801355:	75 10                	jne    801367 <dev_lookup+0x36>
			*dev = devtab[i];
  801357:	89 03                	mov    %eax,(%ebx)
  801359:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80135e:	66 90                	xchg   %ax,%ax
  801360:	eb 36                	jmp    801398 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801362:	be b4 2e 80 00       	mov    $0x802eb4,%esi
  801367:	83 c2 01             	add    $0x1,%edx
  80136a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80136d:	85 c0                	test   %eax,%eax
  80136f:	75 e2                	jne    801353 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  801371:	a1 74 60 80 00       	mov    0x806074,%eax
  801376:	8b 40 4c             	mov    0x4c(%eax),%eax
  801379:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80137d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801381:	c7 04 24 38 2e 80 00 	movl   $0x802e38,(%esp)
  801388:	e8 3c ef ff ff       	call   8002c9 <cprintf>
	*dev = 0;
  80138d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801393:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801398:	83 c4 10             	add    $0x10,%esp
  80139b:	5b                   	pop    %ebx
  80139c:	5e                   	pop    %esi
  80139d:	5d                   	pop    %ebp
  80139e:	c3                   	ret    

0080139f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80139f:	55                   	push   %ebp
  8013a0:	89 e5                	mov    %esp,%ebp
  8013a2:	53                   	push   %ebx
  8013a3:	83 ec 24             	sub    $0x24,%esp
  8013a6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8013a9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8013ac:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013b0:	8b 45 08             	mov    0x8(%ebp),%eax
  8013b3:	89 04 24             	mov    %eax,(%esp)
  8013b6:	e8 02 ff ff ff       	call   8012bd <fd_lookup>
  8013bb:	85 c0                	test   %eax,%eax
  8013bd:	78 53                	js     801412 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8013bf:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8013c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013c6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8013c9:	8b 00                	mov    (%eax),%eax
  8013cb:	89 04 24             	mov    %eax,(%esp)
  8013ce:	e8 5e ff ff ff       	call   801331 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8013d3:	85 c0                	test   %eax,%eax
  8013d5:	78 3b                	js     801412 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  8013d7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8013dc:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8013df:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  8013e3:	74 2d                	je     801412 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8013e5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8013e8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8013ef:	00 00 00 
	stat->st_isdir = 0;
  8013f2:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8013f9:	00 00 00 
	stat->st_dev = dev;
  8013fc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8013ff:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801405:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801409:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80140c:	89 14 24             	mov    %edx,(%esp)
  80140f:	ff 50 14             	call   *0x14(%eax)
}
  801412:	83 c4 24             	add    $0x24,%esp
  801415:	5b                   	pop    %ebx
  801416:	5d                   	pop    %ebp
  801417:	c3                   	ret    

00801418 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801418:	55                   	push   %ebp
  801419:	89 e5                	mov    %esp,%ebp
  80141b:	53                   	push   %ebx
  80141c:	83 ec 24             	sub    $0x24,%esp
  80141f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801422:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801425:	89 44 24 04          	mov    %eax,0x4(%esp)
  801429:	89 1c 24             	mov    %ebx,(%esp)
  80142c:	e8 8c fe ff ff       	call   8012bd <fd_lookup>
  801431:	85 c0                	test   %eax,%eax
  801433:	78 5f                	js     801494 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801435:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801438:	89 44 24 04          	mov    %eax,0x4(%esp)
  80143c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80143f:	8b 00                	mov    (%eax),%eax
  801441:	89 04 24             	mov    %eax,(%esp)
  801444:	e8 e8 fe ff ff       	call   801331 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801449:	85 c0                	test   %eax,%eax
  80144b:	78 47                	js     801494 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80144d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801450:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801454:	75 23                	jne    801479 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801456:	a1 74 60 80 00       	mov    0x806074,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80145b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80145e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801462:	89 44 24 04          	mov    %eax,0x4(%esp)
  801466:	c7 04 24 58 2e 80 00 	movl   $0x802e58,(%esp)
  80146d:	e8 57 ee ff ff       	call   8002c9 <cprintf>
  801472:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801477:	eb 1b                	jmp    801494 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801479:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80147c:	8b 48 18             	mov    0x18(%eax),%ecx
  80147f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801484:	85 c9                	test   %ecx,%ecx
  801486:	74 0c                	je     801494 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801488:	8b 45 0c             	mov    0xc(%ebp),%eax
  80148b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80148f:	89 14 24             	mov    %edx,(%esp)
  801492:	ff d1                	call   *%ecx
}
  801494:	83 c4 24             	add    $0x24,%esp
  801497:	5b                   	pop    %ebx
  801498:	5d                   	pop    %ebp
  801499:	c3                   	ret    

0080149a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80149a:	55                   	push   %ebp
  80149b:	89 e5                	mov    %esp,%ebp
  80149d:	53                   	push   %ebx
  80149e:	83 ec 24             	sub    $0x24,%esp
  8014a1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8014a4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8014a7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014ab:	89 1c 24             	mov    %ebx,(%esp)
  8014ae:	e8 0a fe ff ff       	call   8012bd <fd_lookup>
  8014b3:	85 c0                	test   %eax,%eax
  8014b5:	78 66                	js     80151d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8014b7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8014ba:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014be:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8014c1:	8b 00                	mov    (%eax),%eax
  8014c3:	89 04 24             	mov    %eax,(%esp)
  8014c6:	e8 66 fe ff ff       	call   801331 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8014cb:	85 c0                	test   %eax,%eax
  8014cd:	78 4e                	js     80151d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8014cf:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8014d2:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8014d6:	75 23                	jne    8014fb <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  8014d8:	a1 74 60 80 00       	mov    0x806074,%eax
  8014dd:	8b 40 4c             	mov    0x4c(%eax),%eax
  8014e0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8014e4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014e8:	c7 04 24 79 2e 80 00 	movl   $0x802e79,(%esp)
  8014ef:	e8 d5 ed ff ff       	call   8002c9 <cprintf>
  8014f4:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8014f9:	eb 22                	jmp    80151d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8014fb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8014fe:	8b 48 0c             	mov    0xc(%eax),%ecx
  801501:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801506:	85 c9                	test   %ecx,%ecx
  801508:	74 13                	je     80151d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80150a:	8b 45 10             	mov    0x10(%ebp),%eax
  80150d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801511:	8b 45 0c             	mov    0xc(%ebp),%eax
  801514:	89 44 24 04          	mov    %eax,0x4(%esp)
  801518:	89 14 24             	mov    %edx,(%esp)
  80151b:	ff d1                	call   *%ecx
}
  80151d:	83 c4 24             	add    $0x24,%esp
  801520:	5b                   	pop    %ebx
  801521:	5d                   	pop    %ebp
  801522:	c3                   	ret    

00801523 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801523:	55                   	push   %ebp
  801524:	89 e5                	mov    %esp,%ebp
  801526:	57                   	push   %edi
  801527:	56                   	push   %esi
  801528:	53                   	push   %ebx
  801529:	83 ec 2c             	sub    $0x2c,%esp
  80152c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80152f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801532:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801535:	89 44 24 04          	mov    %eax,0x4(%esp)
  801539:	89 1c 24             	mov    %ebx,(%esp)
  80153c:	e8 7c fd ff ff       	call   8012bd <fd_lookup>
  801541:	85 c0                	test   %eax,%eax
  801543:	0f 88 b0 00 00 00    	js     8015f9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801549:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80154c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801550:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801553:	8b 00                	mov    (%eax),%eax
  801555:	89 04 24             	mov    %eax,(%esp)
  801558:	e8 d4 fd ff ff       	call   801331 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80155d:	85 c0                	test   %eax,%eax
  80155f:	0f 88 94 00 00 00    	js     8015f9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801565:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801568:	8b 40 08             	mov    0x8(%eax),%eax
  80156b:	83 e0 03             	and    $0x3,%eax
  80156e:	83 f8 01             	cmp    $0x1,%eax
  801571:	75 23                	jne    801596 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801573:	a1 74 60 80 00       	mov    0x806074,%eax
  801578:	8b 40 4c             	mov    0x4c(%eax),%eax
  80157b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80157f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801583:	c7 04 24 96 2e 80 00 	movl   $0x802e96,(%esp)
  80158a:	e8 3a ed ff ff       	call   8002c9 <cprintf>
  80158f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801594:	eb 63                	jmp    8015f9 <read+0xd6>
	}
	if (!dev->dev_read)
  801596:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80159b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80159e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  8015a2:	74 55                	je     8015f9 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8015a4:	ba 00 00 00 00       	mov    $0x0,%edx
  8015a9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8015ae:	b8 00 00 00 00       	mov    $0x0,%eax
  8015b3:	85 f6                	test   %esi,%esi
  8015b5:	74 42                	je     8015f9 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  8015b7:	bf 00 10 00 00       	mov    $0x1000,%edi
  8015bc:	89 f0                	mov    %esi,%eax
  8015be:	29 d0                	sub    %edx,%eax
  8015c0:	89 c1                	mov    %eax,%ecx
  8015c2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  8015c8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8015cd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  8015d0:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8015d4:	03 55 0c             	add    0xc(%ebp),%edx
  8015d7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8015db:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8015de:	89 04 24             	mov    %eax,(%esp)
  8015e1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8015e4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  8015e7:	85 c0                	test   %eax,%eax
  8015e9:	78 0e                	js     8015f9 <read+0xd6>
			return m;
		if (m == 0)
  8015eb:	85 c0                	test   %eax,%eax
  8015ed:	74 08                	je     8015f7 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8015ef:	01 c3                	add    %eax,%ebx
  8015f1:	89 da                	mov    %ebx,%edx
  8015f3:	39 f3                	cmp    %esi,%ebx
  8015f5:	72 c5                	jb     8015bc <read+0x99>
  8015f7:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  8015f9:	83 c4 2c             	add    $0x2c,%esp
  8015fc:	5b                   	pop    %ebx
  8015fd:	5e                   	pop    %esi
  8015fe:	5f                   	pop    %edi
  8015ff:	5d                   	pop    %ebp
  801600:	c3                   	ret    

00801601 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801601:	55                   	push   %ebp
  801602:	89 e5                	mov    %esp,%ebp
  801604:	57                   	push   %edi
  801605:	56                   	push   %esi
  801606:	53                   	push   %ebx
  801607:	83 ec 1c             	sub    $0x1c,%esp
  80160a:	8b 7d 08             	mov    0x8(%ebp),%edi
  80160d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801610:	ba 00 00 00 00       	mov    $0x0,%edx
  801615:	bb 00 00 00 00       	mov    $0x0,%ebx
  80161a:	b8 00 00 00 00       	mov    $0x0,%eax
  80161f:	85 f6                	test   %esi,%esi
  801621:	74 29                	je     80164c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801623:	89 f0                	mov    %esi,%eax
  801625:	29 d0                	sub    %edx,%eax
  801627:	89 44 24 08          	mov    %eax,0x8(%esp)
  80162b:	03 55 0c             	add    0xc(%ebp),%edx
  80162e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801632:	89 3c 24             	mov    %edi,(%esp)
  801635:	e8 e9 fe ff ff       	call   801523 <read>
		if (m < 0)
  80163a:	85 c0                	test   %eax,%eax
  80163c:	78 0e                	js     80164c <readn+0x4b>
			return m;
		if (m == 0)
  80163e:	85 c0                	test   %eax,%eax
  801640:	74 08                	je     80164a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801642:	01 c3                	add    %eax,%ebx
  801644:	89 da                	mov    %ebx,%edx
  801646:	39 f3                	cmp    %esi,%ebx
  801648:	72 d9                	jb     801623 <readn+0x22>
  80164a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80164c:	83 c4 1c             	add    $0x1c,%esp
  80164f:	5b                   	pop    %ebx
  801650:	5e                   	pop    %esi
  801651:	5f                   	pop    %edi
  801652:	5d                   	pop    %ebp
  801653:	c3                   	ret    

00801654 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801654:	55                   	push   %ebp
  801655:	89 e5                	mov    %esp,%ebp
  801657:	83 ec 28             	sub    $0x28,%esp
  80165a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80165d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801660:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801663:	89 34 24             	mov    %esi,(%esp)
  801666:	e8 b5 fb ff ff       	call   801220 <fd2num>
  80166b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80166e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801672:	89 04 24             	mov    %eax,(%esp)
  801675:	e8 43 fc ff ff       	call   8012bd <fd_lookup>
  80167a:	89 c3                	mov    %eax,%ebx
  80167c:	85 c0                	test   %eax,%eax
  80167e:	78 05                	js     801685 <fd_close+0x31>
  801680:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801683:	74 0e                	je     801693 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801685:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801689:	b8 00 00 00 00       	mov    $0x0,%eax
  80168e:	0f 44 d8             	cmove  %eax,%ebx
  801691:	eb 3d                	jmp    8016d0 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801693:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801696:	89 44 24 04          	mov    %eax,0x4(%esp)
  80169a:	8b 06                	mov    (%esi),%eax
  80169c:	89 04 24             	mov    %eax,(%esp)
  80169f:	e8 8d fc ff ff       	call   801331 <dev_lookup>
  8016a4:	89 c3                	mov    %eax,%ebx
  8016a6:	85 c0                	test   %eax,%eax
  8016a8:	78 16                	js     8016c0 <fd_close+0x6c>
		if (dev->dev_close)
  8016aa:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8016ad:	8b 40 10             	mov    0x10(%eax),%eax
  8016b0:	bb 00 00 00 00       	mov    $0x0,%ebx
  8016b5:	85 c0                	test   %eax,%eax
  8016b7:	74 07                	je     8016c0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  8016b9:	89 34 24             	mov    %esi,(%esp)
  8016bc:	ff d0                	call   *%eax
  8016be:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  8016c0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8016c4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8016cb:	e8 6a f9 ff ff       	call   80103a <sys_page_unmap>
	return r;
}
  8016d0:	89 d8                	mov    %ebx,%eax
  8016d2:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8016d5:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8016d8:	89 ec                	mov    %ebp,%esp
  8016da:	5d                   	pop    %ebp
  8016db:	c3                   	ret    

008016dc <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  8016dc:	55                   	push   %ebp
  8016dd:	89 e5                	mov    %esp,%ebp
  8016df:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8016e2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8016e5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8016ec:	89 04 24             	mov    %eax,(%esp)
  8016ef:	e8 c9 fb ff ff       	call   8012bd <fd_lookup>
  8016f4:	85 c0                	test   %eax,%eax
  8016f6:	78 13                	js     80170b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  8016f8:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8016ff:	00 
  801700:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801703:	89 04 24             	mov    %eax,(%esp)
  801706:	e8 49 ff ff ff       	call   801654 <fd_close>
}
  80170b:	c9                   	leave  
  80170c:	c3                   	ret    

0080170d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  80170d:	55                   	push   %ebp
  80170e:	89 e5                	mov    %esp,%ebp
  801710:	83 ec 18             	sub    $0x18,%esp
  801713:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801716:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801719:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801720:	00 
  801721:	8b 45 08             	mov    0x8(%ebp),%eax
  801724:	89 04 24             	mov    %eax,(%esp)
  801727:	e8 80 03 00 00       	call   801aac <open>
  80172c:	89 c3                	mov    %eax,%ebx
  80172e:	85 c0                	test   %eax,%eax
  801730:	78 1b                	js     80174d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801732:	8b 45 0c             	mov    0xc(%ebp),%eax
  801735:	89 44 24 04          	mov    %eax,0x4(%esp)
  801739:	89 1c 24             	mov    %ebx,(%esp)
  80173c:	e8 5e fc ff ff       	call   80139f <fstat>
  801741:	89 c6                	mov    %eax,%esi
	close(fd);
  801743:	89 1c 24             	mov    %ebx,(%esp)
  801746:	e8 91 ff ff ff       	call   8016dc <close>
  80174b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80174d:	89 d8                	mov    %ebx,%eax
  80174f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801752:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801755:	89 ec                	mov    %ebp,%esp
  801757:	5d                   	pop    %ebp
  801758:	c3                   	ret    

00801759 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801759:	55                   	push   %ebp
  80175a:	89 e5                	mov    %esp,%ebp
  80175c:	53                   	push   %ebx
  80175d:	83 ec 14             	sub    $0x14,%esp
  801760:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801765:	89 1c 24             	mov    %ebx,(%esp)
  801768:	e8 6f ff ff ff       	call   8016dc <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  80176d:	83 c3 01             	add    $0x1,%ebx
  801770:	83 fb 20             	cmp    $0x20,%ebx
  801773:	75 f0                	jne    801765 <close_all+0xc>
		close(i);
}
  801775:	83 c4 14             	add    $0x14,%esp
  801778:	5b                   	pop    %ebx
  801779:	5d                   	pop    %ebp
  80177a:	c3                   	ret    

0080177b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  80177b:	55                   	push   %ebp
  80177c:	89 e5                	mov    %esp,%ebp
  80177e:	83 ec 58             	sub    $0x58,%esp
  801781:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801784:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801787:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80178a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  80178d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801790:	89 44 24 04          	mov    %eax,0x4(%esp)
  801794:	8b 45 08             	mov    0x8(%ebp),%eax
  801797:	89 04 24             	mov    %eax,(%esp)
  80179a:	e8 1e fb ff ff       	call   8012bd <fd_lookup>
  80179f:	89 c3                	mov    %eax,%ebx
  8017a1:	85 c0                	test   %eax,%eax
  8017a3:	0f 88 e0 00 00 00    	js     801889 <dup+0x10e>
		return r;
	close(newfdnum);
  8017a9:	89 3c 24             	mov    %edi,(%esp)
  8017ac:	e8 2b ff ff ff       	call   8016dc <close>

	newfd = INDEX2FD(newfdnum);
  8017b1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  8017b7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  8017ba:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8017bd:	89 04 24             	mov    %eax,(%esp)
  8017c0:	e8 6b fa ff ff       	call   801230 <fd2data>
  8017c5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8017c7:	89 34 24             	mov    %esi,(%esp)
  8017ca:	e8 61 fa ff ff       	call   801230 <fd2data>
  8017cf:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  8017d2:	89 da                	mov    %ebx,%edx
  8017d4:	89 d8                	mov    %ebx,%eax
  8017d6:	c1 e8 16             	shr    $0x16,%eax
  8017d9:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8017e0:	a8 01                	test   $0x1,%al
  8017e2:	74 43                	je     801827 <dup+0xac>
  8017e4:	c1 ea 0c             	shr    $0xc,%edx
  8017e7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8017ee:	a8 01                	test   $0x1,%al
  8017f0:	74 35                	je     801827 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  8017f2:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8017f9:	25 07 0e 00 00       	and    $0xe07,%eax
  8017fe:	89 44 24 10          	mov    %eax,0x10(%esp)
  801802:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801805:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801809:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801810:	00 
  801811:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801815:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80181c:	e8 77 f8 ff ff       	call   801098 <sys_page_map>
  801821:	89 c3                	mov    %eax,%ebx
  801823:	85 c0                	test   %eax,%eax
  801825:	78 3f                	js     801866 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801827:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80182a:	89 c2                	mov    %eax,%edx
  80182c:	c1 ea 0c             	shr    $0xc,%edx
  80182f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801836:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  80183c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801840:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801844:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80184b:	00 
  80184c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801850:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801857:	e8 3c f8 ff ff       	call   801098 <sys_page_map>
  80185c:	89 c3                	mov    %eax,%ebx
  80185e:	85 c0                	test   %eax,%eax
  801860:	78 04                	js     801866 <dup+0xeb>
  801862:	89 fb                	mov    %edi,%ebx
  801864:	eb 23                	jmp    801889 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801866:	89 74 24 04          	mov    %esi,0x4(%esp)
  80186a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801871:	e8 c4 f7 ff ff       	call   80103a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801876:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801879:	89 44 24 04          	mov    %eax,0x4(%esp)
  80187d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801884:	e8 b1 f7 ff ff       	call   80103a <sys_page_unmap>
	return r;
}
  801889:	89 d8                	mov    %ebx,%eax
  80188b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80188e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801891:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801894:	89 ec                	mov    %ebp,%esp
  801896:	5d                   	pop    %ebp
  801897:	c3                   	ret    

00801898 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801898:	55                   	push   %ebp
  801899:	89 e5                	mov    %esp,%ebp
  80189b:	53                   	push   %ebx
  80189c:	83 ec 14             	sub    $0x14,%esp
  80189f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  8018a1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  8018a7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8018ae:	00 
  8018af:	c7 44 24 08 00 30 80 	movl   $0x803000,0x8(%esp)
  8018b6:	00 
  8018b7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018bb:	89 14 24             	mov    %edx,(%esp)
  8018be:	e8 2d 0e 00 00       	call   8026f0 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  8018c3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8018ca:	00 
  8018cb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8018cf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8018d6:	e8 87 0e 00 00       	call   802762 <ipc_recv>
}
  8018db:	83 c4 14             	add    $0x14,%esp
  8018de:	5b                   	pop    %ebx
  8018df:	5d                   	pop    %ebp
  8018e0:	c3                   	ret    

008018e1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  8018e1:	55                   	push   %ebp
  8018e2:	89 e5                	mov    %esp,%ebp
  8018e4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  8018e7:	8b 45 08             	mov    0x8(%ebp),%eax
  8018ea:	8b 40 0c             	mov    0xc(%eax),%eax
  8018ed:	a3 00 30 80 00       	mov    %eax,0x803000
	fsipcbuf.set_size.req_size = newsize;
  8018f2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8018f5:	a3 04 30 80 00       	mov    %eax,0x803004
	return fsipc(FSREQ_SET_SIZE, NULL);
  8018fa:	ba 00 00 00 00       	mov    $0x0,%edx
  8018ff:	b8 02 00 00 00       	mov    $0x2,%eax
  801904:	e8 8f ff ff ff       	call   801898 <fsipc>
}
  801909:	c9                   	leave  
  80190a:	c3                   	ret    

0080190b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  80190b:	55                   	push   %ebp
  80190c:	89 e5                	mov    %esp,%ebp
  80190e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801911:	8b 45 08             	mov    0x8(%ebp),%eax
  801914:	8b 40 0c             	mov    0xc(%eax),%eax
  801917:	a3 00 30 80 00       	mov    %eax,0x803000
	return fsipc(FSREQ_FLUSH, NULL);
  80191c:	ba 00 00 00 00       	mov    $0x0,%edx
  801921:	b8 06 00 00 00       	mov    $0x6,%eax
  801926:	e8 6d ff ff ff       	call   801898 <fsipc>
}
  80192b:	c9                   	leave  
  80192c:	c3                   	ret    

0080192d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  80192d:	55                   	push   %ebp
  80192e:	89 e5                	mov    %esp,%ebp
  801930:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801933:	ba 00 00 00 00       	mov    $0x0,%edx
  801938:	b8 08 00 00 00       	mov    $0x8,%eax
  80193d:	e8 56 ff ff ff       	call   801898 <fsipc>
}
  801942:	c9                   	leave  
  801943:	c3                   	ret    

00801944 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801944:	55                   	push   %ebp
  801945:	89 e5                	mov    %esp,%ebp
  801947:	53                   	push   %ebx
  801948:	83 ec 14             	sub    $0x14,%esp
  80194b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80194e:	8b 45 08             	mov    0x8(%ebp),%eax
  801951:	8b 40 0c             	mov    0xc(%eax),%eax
  801954:	a3 00 30 80 00       	mov    %eax,0x803000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801959:	ba 00 00 00 00       	mov    $0x0,%edx
  80195e:	b8 05 00 00 00       	mov    $0x5,%eax
  801963:	e8 30 ff ff ff       	call   801898 <fsipc>
  801968:	85 c0                	test   %eax,%eax
  80196a:	78 2b                	js     801997 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80196c:	c7 44 24 04 00 30 80 	movl   $0x803000,0x4(%esp)
  801973:	00 
  801974:	89 1c 24             	mov    %ebx,(%esp)
  801977:	e8 1e f0 ff ff       	call   80099a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  80197c:	a1 80 30 80 00       	mov    0x803080,%eax
  801981:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801987:	a1 84 30 80 00       	mov    0x803084,%eax
  80198c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801992:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801997:	83 c4 14             	add    $0x14,%esp
  80199a:	5b                   	pop    %ebx
  80199b:	5d                   	pop    %ebp
  80199c:	c3                   	ret    

0080199d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  80199d:	55                   	push   %ebp
  80199e:	89 e5                	mov    %esp,%ebp
  8019a0:	53                   	push   %ebx
  8019a1:	83 ec 14             	sub    $0x14,%esp
  8019a4:	8b 45 08             	mov    0x8(%ebp),%eax
  8019a7:	8b 55 0c             	mov    0xc(%ebp),%edx
  8019aa:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  8019ad:	85 c0                	test   %eax,%eax
  8019af:	74 44                	je     8019f5 <devfile_write+0x58>
  8019b1:	85 d2                	test   %edx,%edx
  8019b3:	74 40                	je     8019f5 <devfile_write+0x58>
  8019b5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  8019bb:	77 38                	ja     8019f5 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  8019bd:	8b 40 0c             	mov    0xc(%eax),%eax
  8019c0:	a3 00 30 80 00       	mov    %eax,0x803000
    fsipcbuf.write.req_n        = n;
  8019c5:	89 1d 04 30 80 00    	mov    %ebx,0x803004
    memmove(fsipcbuf.write.req_buf, buf, n);
  8019cb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8019cf:	89 54 24 04          	mov    %edx,0x4(%esp)
  8019d3:	c7 04 24 08 30 80 00 	movl   $0x803008,(%esp)
  8019da:	e8 76 f1 ff ff       	call   800b55 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  8019df:	ba 00 00 00 00       	mov    $0x0,%edx
  8019e4:	b8 04 00 00 00       	mov    $0x4,%eax
  8019e9:	e8 aa fe ff ff       	call   801898 <fsipc>
        return r;
    return n;
  8019ee:	85 c0                	test   %eax,%eax
  8019f0:	0f 49 c3             	cmovns %ebx,%eax
  8019f3:	eb 05                	jmp    8019fa <devfile_write+0x5d>
  8019f5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8019fa:	83 c4 14             	add    $0x14,%esp
  8019fd:	5b                   	pop    %ebx
  8019fe:	5d                   	pop    %ebp
  8019ff:	c3                   	ret    

00801a00 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801a00:	55                   	push   %ebp
  801a01:	89 e5                	mov    %esp,%ebp
  801a03:	83 ec 18             	sub    $0x18,%esp
  801a06:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801a09:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801a0c:	8b 45 08             	mov    0x8(%ebp),%eax
  801a0f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801a12:	85 c0                	test   %eax,%eax
  801a14:	74 04                	je     801a1a <devfile_read+0x1a>
  801a16:	85 f6                	test   %esi,%esi
  801a18:	75 07                	jne    801a21 <devfile_read+0x21>
  801a1a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801a1f:	eb 39                	jmp    801a5a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801a21:	8b 40 0c             	mov    0xc(%eax),%eax
  801a24:	a3 00 30 80 00       	mov    %eax,0x803000
  fsipcbuf.read.req_n         = n;
  801a29:	8b 45 10             	mov    0x10(%ebp),%eax
  801a2c:	a3 04 30 80 00       	mov    %eax,0x803004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801a31:	ba 00 00 00 00       	mov    $0x0,%edx
  801a36:	b8 03 00 00 00       	mov    $0x3,%eax
  801a3b:	e8 58 fe ff ff       	call   801898 <fsipc>
  801a40:	89 c3                	mov    %eax,%ebx
  801a42:	85 c0                	test   %eax,%eax
  801a44:	78 14                	js     801a5a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801a46:	89 44 24 08          	mov    %eax,0x8(%esp)
  801a4a:	c7 44 24 04 00 30 80 	movl   $0x803000,0x4(%esp)
  801a51:	00 
  801a52:	89 34 24             	mov    %esi,(%esp)
  801a55:	e8 fb f0 ff ff       	call   800b55 <memmove>
  return r;
}
  801a5a:	89 d8                	mov    %ebx,%eax
  801a5c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801a5f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801a62:	89 ec                	mov    %ebp,%esp
  801a64:	5d                   	pop    %ebp
  801a65:	c3                   	ret    

00801a66 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801a66:	55                   	push   %ebp
  801a67:	89 e5                	mov    %esp,%ebp
  801a69:	53                   	push   %ebx
  801a6a:	83 ec 14             	sub    $0x14,%esp
  801a6d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801a70:	89 1c 24             	mov    %ebx,(%esp)
  801a73:	e8 d8 ee ff ff       	call   800950 <strlen>
  801a78:	89 c2                	mov    %eax,%edx
  801a7a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801a7f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801a85:	7f 1f                	jg     801aa6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801a87:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801a8b:	c7 04 24 00 30 80 00 	movl   $0x803000,(%esp)
  801a92:	e8 03 ef ff ff       	call   80099a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801a97:	ba 00 00 00 00       	mov    $0x0,%edx
  801a9c:	b8 07 00 00 00       	mov    $0x7,%eax
  801aa1:	e8 f2 fd ff ff       	call   801898 <fsipc>
}
  801aa6:	83 c4 14             	add    $0x14,%esp
  801aa9:	5b                   	pop    %ebx
  801aaa:	5d                   	pop    %ebp
  801aab:	c3                   	ret    

00801aac <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801aac:	55                   	push   %ebp
  801aad:	89 e5                	mov    %esp,%ebp
  801aaf:	83 ec 28             	sub    $0x28,%esp
  801ab2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801ab5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801ab8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801abb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801ac0:	85 f6                	test   %esi,%esi
  801ac2:	74 65                	je     801b29 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801ac4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801acb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801ace:	89 04 24             	mov    %eax,(%esp)
  801ad1:	e8 75 f7 ff ff       	call   80124b <fd_alloc>
  801ad6:	89 c3                	mov    %eax,%ebx
  801ad8:	85 c0                	test   %eax,%eax
  801ada:	78 4d                	js     801b29 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801adc:	89 74 24 04          	mov    %esi,0x4(%esp)
  801ae0:	c7 04 24 00 30 80 00 	movl   $0x803000,(%esp)
  801ae7:	e8 ae ee ff ff       	call   80099a <strcpy>
	fsipcbuf.open.req_omode = mode;
  801aec:	8b 45 0c             	mov    0xc(%ebp),%eax
  801aef:	a3 00 34 80 00       	mov    %eax,0x803400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801af4:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801af7:	b8 01 00 00 00       	mov    $0x1,%eax
  801afc:	e8 97 fd ff ff       	call   801898 <fsipc>
  801b01:	89 c3                	mov    %eax,%ebx
  801b03:	85 c0                	test   %eax,%eax
  801b05:	79 15                	jns    801b1c <open+0x70>
    fd_close(f, 0);
  801b07:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801b0e:	00 
  801b0f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801b12:	89 04 24             	mov    %eax,(%esp)
  801b15:	e8 3a fb ff ff       	call   801654 <fd_close>
    return r;
  801b1a:	eb 0d                	jmp    801b29 <open+0x7d>
  }
  return fd2num(f);
  801b1c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801b1f:	89 04 24             	mov    %eax,(%esp)
  801b22:	e8 f9 f6 ff ff       	call   801220 <fd2num>
  801b27:	89 c3                	mov    %eax,%ebx
}
  801b29:	89 d8                	mov    %ebx,%eax
  801b2b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801b2e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801b31:	89 ec                	mov    %ebp,%esp
  801b33:	5d                   	pop    %ebp
  801b34:	c3                   	ret    
  801b35:	00 00                	add    %al,(%eax)
	...

00801b38 <writebuf>:
};


static void
writebuf(struct printbuf *b)
{
  801b38:	55                   	push   %ebp
  801b39:	89 e5                	mov    %esp,%ebp
  801b3b:	53                   	push   %ebx
  801b3c:	83 ec 14             	sub    $0x14,%esp
  801b3f:	89 c3                	mov    %eax,%ebx
	if (b->error > 0) {
  801b41:	83 78 0c 00          	cmpl   $0x0,0xc(%eax)
  801b45:	7e 31                	jle    801b78 <writebuf+0x40>
		ssize_t result = write(b->fd, b->buf, b->idx);
  801b47:	8b 40 04             	mov    0x4(%eax),%eax
  801b4a:	89 44 24 08          	mov    %eax,0x8(%esp)
  801b4e:	8d 43 10             	lea    0x10(%ebx),%eax
  801b51:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b55:	8b 03                	mov    (%ebx),%eax
  801b57:	89 04 24             	mov    %eax,(%esp)
  801b5a:	e8 3b f9 ff ff       	call   80149a <write>
		if (result > 0)
  801b5f:	85 c0                	test   %eax,%eax
  801b61:	7e 03                	jle    801b66 <writebuf+0x2e>
			b->result += result;
  801b63:	01 43 08             	add    %eax,0x8(%ebx)
		if (result != b->idx) // error, or wrote less than supplied
  801b66:	3b 43 04             	cmp    0x4(%ebx),%eax
  801b69:	74 0d                	je     801b78 <writebuf+0x40>
			b->error = (result < 0 ? result : 0);
  801b6b:	85 c0                	test   %eax,%eax
  801b6d:	ba 00 00 00 00       	mov    $0x0,%edx
  801b72:	0f 4f c2             	cmovg  %edx,%eax
  801b75:	89 43 0c             	mov    %eax,0xc(%ebx)
	}
}
  801b78:	83 c4 14             	add    $0x14,%esp
  801b7b:	5b                   	pop    %ebx
  801b7c:	5d                   	pop    %ebp
  801b7d:	c3                   	ret    

00801b7e <vfprintf>:
	}
}

int
vfprintf(int fd, const char *fmt, va_list ap)
{
  801b7e:	55                   	push   %ebp
  801b7f:	89 e5                	mov    %esp,%ebp
  801b81:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.fd = fd;
  801b87:	8b 45 08             	mov    0x8(%ebp),%eax
  801b8a:	89 85 e8 fe ff ff    	mov    %eax,-0x118(%ebp)
	b.idx = 0;
  801b90:	c7 85 ec fe ff ff 00 	movl   $0x0,-0x114(%ebp)
  801b97:	00 00 00 
	b.result = 0;
  801b9a:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  801ba1:	00 00 00 
	b.error = 1;
  801ba4:	c7 85 f4 fe ff ff 01 	movl   $0x1,-0x10c(%ebp)
  801bab:	00 00 00 
	vprintfmt(putch, &b, fmt, ap);
  801bae:	8b 45 10             	mov    0x10(%ebp),%eax
  801bb1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801bb5:	8b 45 0c             	mov    0xc(%ebp),%eax
  801bb8:	89 44 24 08          	mov    %eax,0x8(%esp)
  801bbc:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  801bc2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bc6:	c7 04 24 3a 1c 80 00 	movl   $0x801c3a,(%esp)
  801bcd:	e8 ab e8 ff ff       	call   80047d <vprintfmt>
	if (b.idx > 0)
  801bd2:	83 bd ec fe ff ff 00 	cmpl   $0x0,-0x114(%ebp)
  801bd9:	7e 0b                	jle    801be6 <vfprintf+0x68>
		writebuf(&b);
  801bdb:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  801be1:	e8 52 ff ff ff       	call   801b38 <writebuf>

	return (b.result ? b.result : b.error);
  801be6:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  801bec:	85 c0                	test   %eax,%eax
  801bee:	0f 44 85 f4 fe ff ff 	cmove  -0x10c(%ebp),%eax
}
  801bf5:	c9                   	leave  
  801bf6:	c3                   	ret    

00801bf7 <printf>:
	return cnt;
}

int
printf(const char *fmt, ...)
{
  801bf7:	55                   	push   %ebp
  801bf8:	89 e5                	mov    %esp,%ebp
  801bfa:	83 ec 18             	sub    $0x18,%esp

	return cnt;
}

int
printf(const char *fmt, ...)
  801bfd:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(1, fmt, ap);
  801c00:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c04:	8b 45 08             	mov    0x8(%ebp),%eax
  801c07:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c0b:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  801c12:	e8 67 ff ff ff       	call   801b7e <vfprintf>
	va_end(ap);

	return cnt;
}
  801c17:	c9                   	leave  
  801c18:	c3                   	ret    

00801c19 <fprintf>:
	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
{
  801c19:	55                   	push   %ebp
  801c1a:	89 e5                	mov    %esp,%ebp
  801c1c:	83 ec 18             	sub    $0x18,%esp

	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
  801c1f:	8d 45 10             	lea    0x10(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(fd, fmt, ap);
  801c22:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c26:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c29:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c2d:	8b 45 08             	mov    0x8(%ebp),%eax
  801c30:	89 04 24             	mov    %eax,(%esp)
  801c33:	e8 46 ff ff ff       	call   801b7e <vfprintf>
	va_end(ap);

	return cnt;
}
  801c38:	c9                   	leave  
  801c39:	c3                   	ret    

00801c3a <putch>:
	}
}

static void
putch(int ch, void *thunk)
{
  801c3a:	55                   	push   %ebp
  801c3b:	89 e5                	mov    %esp,%ebp
  801c3d:	53                   	push   %ebx
  801c3e:	83 ec 04             	sub    $0x4,%esp
	struct printbuf *b = (struct printbuf *) thunk;
  801c41:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  801c44:	8b 43 04             	mov    0x4(%ebx),%eax
  801c47:	8b 55 08             	mov    0x8(%ebp),%edx
  801c4a:	88 54 03 10          	mov    %dl,0x10(%ebx,%eax,1)
  801c4e:	83 c0 01             	add    $0x1,%eax
  801c51:	89 43 04             	mov    %eax,0x4(%ebx)
	if (b->idx == 256) {
  801c54:	3d 00 01 00 00       	cmp    $0x100,%eax
  801c59:	75 0e                	jne    801c69 <putch+0x2f>
		writebuf(b);
  801c5b:	89 d8                	mov    %ebx,%eax
  801c5d:	e8 d6 fe ff ff       	call   801b38 <writebuf>
		b->idx = 0;
  801c62:	c7 43 04 00 00 00 00 	movl   $0x0,0x4(%ebx)
	}
}
  801c69:	83 c4 04             	add    $0x4,%esp
  801c6c:	5b                   	pop    %ebx
  801c6d:	5d                   	pop    %ebp
  801c6e:	c3                   	ret    
	...

00801c70 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  801c70:	55                   	push   %ebp
  801c71:	89 e5                	mov    %esp,%ebp
  801c73:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  801c76:	c7 44 24 04 c8 2e 80 	movl   $0x802ec8,0x4(%esp)
  801c7d:	00 
  801c7e:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c81:	89 04 24             	mov    %eax,(%esp)
  801c84:	e8 11 ed ff ff       	call   80099a <strcpy>
	return 0;
}
  801c89:	b8 00 00 00 00       	mov    $0x0,%eax
  801c8e:	c9                   	leave  
  801c8f:	c3                   	ret    

00801c90 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  801c90:	55                   	push   %ebp
  801c91:	89 e5                	mov    %esp,%ebp
  801c93:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  801c96:	8b 45 08             	mov    0x8(%ebp),%eax
  801c99:	8b 40 0c             	mov    0xc(%eax),%eax
  801c9c:	89 04 24             	mov    %eax,(%esp)
  801c9f:	e8 9d 02 00 00       	call   801f41 <nsipc_close>
}
  801ca4:	c9                   	leave  
  801ca5:	c3                   	ret    

00801ca6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  801ca6:	55                   	push   %ebp
  801ca7:	89 e5                	mov    %esp,%ebp
  801ca9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  801cac:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801cb3:	00 
  801cb4:	8b 45 10             	mov    0x10(%ebp),%eax
  801cb7:	89 44 24 08          	mov    %eax,0x8(%esp)
  801cbb:	8b 45 0c             	mov    0xc(%ebp),%eax
  801cbe:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cc2:	8b 45 08             	mov    0x8(%ebp),%eax
  801cc5:	8b 40 0c             	mov    0xc(%eax),%eax
  801cc8:	89 04 24             	mov    %eax,(%esp)
  801ccb:	e8 ad 02 00 00       	call   801f7d <nsipc_send>
}
  801cd0:	c9                   	leave  
  801cd1:	c3                   	ret    

00801cd2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  801cd2:	55                   	push   %ebp
  801cd3:	89 e5                	mov    %esp,%ebp
  801cd5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  801cd8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801cdf:	00 
  801ce0:	8b 45 10             	mov    0x10(%ebp),%eax
  801ce3:	89 44 24 08          	mov    %eax,0x8(%esp)
  801ce7:	8b 45 0c             	mov    0xc(%ebp),%eax
  801cea:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cee:	8b 45 08             	mov    0x8(%ebp),%eax
  801cf1:	8b 40 0c             	mov    0xc(%eax),%eax
  801cf4:	89 04 24             	mov    %eax,(%esp)
  801cf7:	e8 f4 02 00 00       	call   801ff0 <nsipc_recv>
}
  801cfc:	c9                   	leave  
  801cfd:	c3                   	ret    

00801cfe <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  801cfe:	55                   	push   %ebp
  801cff:	89 e5                	mov    %esp,%ebp
  801d01:	56                   	push   %esi
  801d02:	53                   	push   %ebx
  801d03:	83 ec 20             	sub    $0x20,%esp
  801d06:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801d08:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d0b:	89 04 24             	mov    %eax,(%esp)
  801d0e:	e8 38 f5 ff ff       	call   80124b <fd_alloc>
  801d13:	89 c3                	mov    %eax,%ebx
  801d15:	85 c0                	test   %eax,%eax
  801d17:	78 21                	js     801d3a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  801d19:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801d20:	00 
  801d21:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d24:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d28:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d2f:	e8 c2 f3 ff ff       	call   8010f6 <sys_page_alloc>
  801d34:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801d36:	85 c0                	test   %eax,%eax
  801d38:	79 0a                	jns    801d44 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  801d3a:	89 34 24             	mov    %esi,(%esp)
  801d3d:	e8 ff 01 00 00       	call   801f41 <nsipc_close>
		return r;
  801d42:	eb 28                	jmp    801d6c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  801d44:	8b 15 20 60 80 00    	mov    0x806020,%edx
  801d4a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d4d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  801d4f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d52:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  801d59:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d5c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  801d5f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d62:	89 04 24             	mov    %eax,(%esp)
  801d65:	e8 b6 f4 ff ff       	call   801220 <fd2num>
  801d6a:	89 c3                	mov    %eax,%ebx
}
  801d6c:	89 d8                	mov    %ebx,%eax
  801d6e:	83 c4 20             	add    $0x20,%esp
  801d71:	5b                   	pop    %ebx
  801d72:	5e                   	pop    %esi
  801d73:	5d                   	pop    %ebp
  801d74:	c3                   	ret    

00801d75 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  801d75:	55                   	push   %ebp
  801d76:	89 e5                	mov    %esp,%ebp
  801d78:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  801d7b:	8b 45 10             	mov    0x10(%ebp),%eax
  801d7e:	89 44 24 08          	mov    %eax,0x8(%esp)
  801d82:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d85:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d89:	8b 45 08             	mov    0x8(%ebp),%eax
  801d8c:	89 04 24             	mov    %eax,(%esp)
  801d8f:	e8 61 01 00 00       	call   801ef5 <nsipc_socket>
  801d94:	85 c0                	test   %eax,%eax
  801d96:	78 05                	js     801d9d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  801d98:	e8 61 ff ff ff       	call   801cfe <alloc_sockfd>
}
  801d9d:	c9                   	leave  
  801d9e:	66 90                	xchg   %ax,%ax
  801da0:	c3                   	ret    

00801da1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  801da1:	55                   	push   %ebp
  801da2:	89 e5                	mov    %esp,%ebp
  801da4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  801da7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801daa:	89 54 24 04          	mov    %edx,0x4(%esp)
  801dae:	89 04 24             	mov    %eax,(%esp)
  801db1:	e8 07 f5 ff ff       	call   8012bd <fd_lookup>
  801db6:	85 c0                	test   %eax,%eax
  801db8:	78 15                	js     801dcf <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  801dba:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801dbd:	8b 0a                	mov    (%edx),%ecx
  801dbf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801dc4:	3b 0d 20 60 80 00    	cmp    0x806020,%ecx
  801dca:	75 03                	jne    801dcf <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  801dcc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  801dcf:	c9                   	leave  
  801dd0:	c3                   	ret    

00801dd1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  801dd1:	55                   	push   %ebp
  801dd2:	89 e5                	mov    %esp,%ebp
  801dd4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801dd7:	8b 45 08             	mov    0x8(%ebp),%eax
  801dda:	e8 c2 ff ff ff       	call   801da1 <fd2sockid>
  801ddf:	85 c0                	test   %eax,%eax
  801de1:	78 0f                	js     801df2 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  801de3:	8b 55 0c             	mov    0xc(%ebp),%edx
  801de6:	89 54 24 04          	mov    %edx,0x4(%esp)
  801dea:	89 04 24             	mov    %eax,(%esp)
  801ded:	e8 2d 01 00 00       	call   801f1f <nsipc_listen>
}
  801df2:	c9                   	leave  
  801df3:	c3                   	ret    

00801df4 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  801df4:	55                   	push   %ebp
  801df5:	89 e5                	mov    %esp,%ebp
  801df7:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801dfa:	8b 45 08             	mov    0x8(%ebp),%eax
  801dfd:	e8 9f ff ff ff       	call   801da1 <fd2sockid>
  801e02:	85 c0                	test   %eax,%eax
  801e04:	78 16                	js     801e1c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  801e06:	8b 55 10             	mov    0x10(%ebp),%edx
  801e09:	89 54 24 08          	mov    %edx,0x8(%esp)
  801e0d:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e10:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e14:	89 04 24             	mov    %eax,(%esp)
  801e17:	e8 54 02 00 00       	call   802070 <nsipc_connect>
}
  801e1c:	c9                   	leave  
  801e1d:	c3                   	ret    

00801e1e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  801e1e:	55                   	push   %ebp
  801e1f:	89 e5                	mov    %esp,%ebp
  801e21:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e24:	8b 45 08             	mov    0x8(%ebp),%eax
  801e27:	e8 75 ff ff ff       	call   801da1 <fd2sockid>
  801e2c:	85 c0                	test   %eax,%eax
  801e2e:	78 0f                	js     801e3f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  801e30:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e33:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e37:	89 04 24             	mov    %eax,(%esp)
  801e3a:	e8 1c 01 00 00       	call   801f5b <nsipc_shutdown>
}
  801e3f:	c9                   	leave  
  801e40:	c3                   	ret    

00801e41 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  801e41:	55                   	push   %ebp
  801e42:	89 e5                	mov    %esp,%ebp
  801e44:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e47:	8b 45 08             	mov    0x8(%ebp),%eax
  801e4a:	e8 52 ff ff ff       	call   801da1 <fd2sockid>
  801e4f:	85 c0                	test   %eax,%eax
  801e51:	78 16                	js     801e69 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  801e53:	8b 55 10             	mov    0x10(%ebp),%edx
  801e56:	89 54 24 08          	mov    %edx,0x8(%esp)
  801e5a:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e5d:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e61:	89 04 24             	mov    %eax,(%esp)
  801e64:	e8 46 02 00 00       	call   8020af <nsipc_bind>
}
  801e69:	c9                   	leave  
  801e6a:	c3                   	ret    

00801e6b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  801e6b:	55                   	push   %ebp
  801e6c:	89 e5                	mov    %esp,%ebp
  801e6e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e71:	8b 45 08             	mov    0x8(%ebp),%eax
  801e74:	e8 28 ff ff ff       	call   801da1 <fd2sockid>
  801e79:	85 c0                	test   %eax,%eax
  801e7b:	78 1f                	js     801e9c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  801e7d:	8b 55 10             	mov    0x10(%ebp),%edx
  801e80:	89 54 24 08          	mov    %edx,0x8(%esp)
  801e84:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e87:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e8b:	89 04 24             	mov    %eax,(%esp)
  801e8e:	e8 5b 02 00 00       	call   8020ee <nsipc_accept>
  801e93:	85 c0                	test   %eax,%eax
  801e95:	78 05                	js     801e9c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  801e97:	e8 62 fe ff ff       	call   801cfe <alloc_sockfd>
}
  801e9c:	c9                   	leave  
  801e9d:	8d 76 00             	lea    0x0(%esi),%esi
  801ea0:	c3                   	ret    
	...

00801eb0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  801eb0:	55                   	push   %ebp
  801eb1:	89 e5                	mov    %esp,%ebp
  801eb3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  801eb6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  801ebc:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801ec3:	00 
  801ec4:	c7 44 24 08 00 50 80 	movl   $0x805000,0x8(%esp)
  801ecb:	00 
  801ecc:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ed0:	89 14 24             	mov    %edx,(%esp)
  801ed3:	e8 18 08 00 00       	call   8026f0 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  801ed8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801edf:	00 
  801ee0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801ee7:	00 
  801ee8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801eeb:	89 04 24             	mov    %eax,(%esp)
  801eee:	e8 6f 08 00 00       	call   802762 <ipc_recv>
    return r;
}
  801ef3:	c9                   	leave  
  801ef4:	c3                   	ret    

00801ef5 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  801ef5:	55                   	push   %ebp
  801ef6:	89 e5                	mov    %esp,%ebp
  801ef8:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  801efb:	8b 45 08             	mov    0x8(%ebp),%eax
  801efe:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.socket.req_type = type;
  801f03:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f06:	a3 04 50 80 00       	mov    %eax,0x805004
	nsipcbuf.socket.req_protocol = protocol;
  801f0b:	8b 45 10             	mov    0x10(%ebp),%eax
  801f0e:	a3 08 50 80 00       	mov    %eax,0x805008
	return nsipc(NSREQ_SOCKET);
  801f13:	b8 09 00 00 00       	mov    $0x9,%eax
  801f18:	e8 93 ff ff ff       	call   801eb0 <nsipc>
}
  801f1d:	c9                   	leave  
  801f1e:	c3                   	ret    

00801f1f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  801f1f:	55                   	push   %ebp
  801f20:	89 e5                	mov    %esp,%ebp
  801f22:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  801f25:	8b 45 08             	mov    0x8(%ebp),%eax
  801f28:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.listen.req_backlog = backlog;
  801f2d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f30:	a3 04 50 80 00       	mov    %eax,0x805004
	return nsipc(NSREQ_LISTEN);
  801f35:	b8 06 00 00 00       	mov    $0x6,%eax
  801f3a:	e8 71 ff ff ff       	call   801eb0 <nsipc>
}
  801f3f:	c9                   	leave  
  801f40:	c3                   	ret    

00801f41 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  801f41:	55                   	push   %ebp
  801f42:	89 e5                	mov    %esp,%ebp
  801f44:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  801f47:	8b 45 08             	mov    0x8(%ebp),%eax
  801f4a:	a3 00 50 80 00       	mov    %eax,0x805000
	return nsipc(NSREQ_CLOSE);
  801f4f:	b8 04 00 00 00       	mov    $0x4,%eax
  801f54:	e8 57 ff ff ff       	call   801eb0 <nsipc>
}
  801f59:	c9                   	leave  
  801f5a:	c3                   	ret    

00801f5b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  801f5b:	55                   	push   %ebp
  801f5c:	89 e5                	mov    %esp,%ebp
  801f5e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  801f61:	8b 45 08             	mov    0x8(%ebp),%eax
  801f64:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.shutdown.req_how = how;
  801f69:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f6c:	a3 04 50 80 00       	mov    %eax,0x805004
	return nsipc(NSREQ_SHUTDOWN);
  801f71:	b8 03 00 00 00       	mov    $0x3,%eax
  801f76:	e8 35 ff ff ff       	call   801eb0 <nsipc>
}
  801f7b:	c9                   	leave  
  801f7c:	c3                   	ret    

00801f7d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  801f7d:	55                   	push   %ebp
  801f7e:	89 e5                	mov    %esp,%ebp
  801f80:	53                   	push   %ebx
  801f81:	83 ec 14             	sub    $0x14,%esp
  801f84:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  801f87:	8b 45 08             	mov    0x8(%ebp),%eax
  801f8a:	a3 00 50 80 00       	mov    %eax,0x805000
	assert(size < 1600);
  801f8f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  801f95:	7e 24                	jle    801fbb <nsipc_send+0x3e>
  801f97:	c7 44 24 0c d4 2e 80 	movl   $0x802ed4,0xc(%esp)
  801f9e:	00 
  801f9f:	c7 44 24 08 e0 2e 80 	movl   $0x802ee0,0x8(%esp)
  801fa6:	00 
  801fa7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  801fae:	00 
  801faf:	c7 04 24 f5 2e 80 00 	movl   $0x802ef5,(%esp)
  801fb6:	e8 49 e2 ff ff       	call   800204 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  801fbb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801fbf:	8b 45 0c             	mov    0xc(%ebp),%eax
  801fc2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801fc6:	c7 04 24 0c 50 80 00 	movl   $0x80500c,(%esp)
  801fcd:	e8 83 eb ff ff       	call   800b55 <memmove>
	nsipcbuf.send.req_size = size;
  801fd2:	89 1d 04 50 80 00    	mov    %ebx,0x805004
	nsipcbuf.send.req_flags = flags;
  801fd8:	8b 45 14             	mov    0x14(%ebp),%eax
  801fdb:	a3 08 50 80 00       	mov    %eax,0x805008
	return nsipc(NSREQ_SEND);
  801fe0:	b8 08 00 00 00       	mov    $0x8,%eax
  801fe5:	e8 c6 fe ff ff       	call   801eb0 <nsipc>
}
  801fea:	83 c4 14             	add    $0x14,%esp
  801fed:	5b                   	pop    %ebx
  801fee:	5d                   	pop    %ebp
  801fef:	c3                   	ret    

00801ff0 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  801ff0:	55                   	push   %ebp
  801ff1:	89 e5                	mov    %esp,%ebp
  801ff3:	56                   	push   %esi
  801ff4:	53                   	push   %ebx
  801ff5:	83 ec 10             	sub    $0x10,%esp
  801ff8:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  801ffb:	8b 45 08             	mov    0x8(%ebp),%eax
  801ffe:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.recv.req_len = len;
  802003:	89 35 04 50 80 00    	mov    %esi,0x805004
	nsipcbuf.recv.req_flags = flags;
  802009:	8b 45 14             	mov    0x14(%ebp),%eax
  80200c:	a3 08 50 80 00       	mov    %eax,0x805008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802011:	b8 07 00 00 00       	mov    $0x7,%eax
  802016:	e8 95 fe ff ff       	call   801eb0 <nsipc>
  80201b:	89 c3                	mov    %eax,%ebx
  80201d:	85 c0                	test   %eax,%eax
  80201f:	78 46                	js     802067 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802021:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802026:	7f 04                	jg     80202c <nsipc_recv+0x3c>
  802028:	39 c6                	cmp    %eax,%esi
  80202a:	7d 24                	jge    802050 <nsipc_recv+0x60>
  80202c:	c7 44 24 0c 01 2f 80 	movl   $0x802f01,0xc(%esp)
  802033:	00 
  802034:	c7 44 24 08 e0 2e 80 	movl   $0x802ee0,0x8(%esp)
  80203b:	00 
  80203c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802043:	00 
  802044:	c7 04 24 f5 2e 80 00 	movl   $0x802ef5,(%esp)
  80204b:	e8 b4 e1 ff ff       	call   800204 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802050:	89 44 24 08          	mov    %eax,0x8(%esp)
  802054:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  80205b:	00 
  80205c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80205f:	89 04 24             	mov    %eax,(%esp)
  802062:	e8 ee ea ff ff       	call   800b55 <memmove>
	}

	return r;
}
  802067:	89 d8                	mov    %ebx,%eax
  802069:	83 c4 10             	add    $0x10,%esp
  80206c:	5b                   	pop    %ebx
  80206d:	5e                   	pop    %esi
  80206e:	5d                   	pop    %ebp
  80206f:	c3                   	ret    

00802070 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802070:	55                   	push   %ebp
  802071:	89 e5                	mov    %esp,%ebp
  802073:	53                   	push   %ebx
  802074:	83 ec 14             	sub    $0x14,%esp
  802077:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80207a:	8b 45 08             	mov    0x8(%ebp),%eax
  80207d:	a3 00 50 80 00       	mov    %eax,0x805000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802082:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802086:	8b 45 0c             	mov    0xc(%ebp),%eax
  802089:	89 44 24 04          	mov    %eax,0x4(%esp)
  80208d:	c7 04 24 04 50 80 00 	movl   $0x805004,(%esp)
  802094:	e8 bc ea ff ff       	call   800b55 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  802099:	89 1d 14 50 80 00    	mov    %ebx,0x805014
	return nsipc(NSREQ_CONNECT);
  80209f:	b8 05 00 00 00       	mov    $0x5,%eax
  8020a4:	e8 07 fe ff ff       	call   801eb0 <nsipc>
}
  8020a9:	83 c4 14             	add    $0x14,%esp
  8020ac:	5b                   	pop    %ebx
  8020ad:	5d                   	pop    %ebp
  8020ae:	c3                   	ret    

008020af <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8020af:	55                   	push   %ebp
  8020b0:	89 e5                	mov    %esp,%ebp
  8020b2:	53                   	push   %ebx
  8020b3:	83 ec 14             	sub    $0x14,%esp
  8020b6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8020b9:	8b 45 08             	mov    0x8(%ebp),%eax
  8020bc:	a3 00 50 80 00       	mov    %eax,0x805000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8020c1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8020c5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020c8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020cc:	c7 04 24 04 50 80 00 	movl   $0x805004,(%esp)
  8020d3:	e8 7d ea ff ff       	call   800b55 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  8020d8:	89 1d 14 50 80 00    	mov    %ebx,0x805014
	return nsipc(NSREQ_BIND);
  8020de:	b8 02 00 00 00       	mov    $0x2,%eax
  8020e3:	e8 c8 fd ff ff       	call   801eb0 <nsipc>
}
  8020e8:	83 c4 14             	add    $0x14,%esp
  8020eb:	5b                   	pop    %ebx
  8020ec:	5d                   	pop    %ebp
  8020ed:	c3                   	ret    

008020ee <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8020ee:	55                   	push   %ebp
  8020ef:	89 e5                	mov    %esp,%ebp
  8020f1:	83 ec 18             	sub    $0x18,%esp
  8020f4:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8020f7:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  8020fa:	8b 45 08             	mov    0x8(%ebp),%eax
  8020fd:	a3 00 50 80 00       	mov    %eax,0x805000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802102:	b8 01 00 00 00       	mov    $0x1,%eax
  802107:	e8 a4 fd ff ff       	call   801eb0 <nsipc>
  80210c:	89 c3                	mov    %eax,%ebx
  80210e:	85 c0                	test   %eax,%eax
  802110:	78 25                	js     802137 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802112:	be 10 50 80 00       	mov    $0x805010,%esi
  802117:	8b 06                	mov    (%esi),%eax
  802119:	89 44 24 08          	mov    %eax,0x8(%esp)
  80211d:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  802124:	00 
  802125:	8b 45 0c             	mov    0xc(%ebp),%eax
  802128:	89 04 24             	mov    %eax,(%esp)
  80212b:	e8 25 ea ff ff       	call   800b55 <memmove>
		*addrlen = ret->ret_addrlen;
  802130:	8b 16                	mov    (%esi),%edx
  802132:	8b 45 10             	mov    0x10(%ebp),%eax
  802135:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802137:	89 d8                	mov    %ebx,%eax
  802139:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80213c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80213f:	89 ec                	mov    %ebp,%esp
  802141:	5d                   	pop    %ebp
  802142:	c3                   	ret    
	...

00802150 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802150:	55                   	push   %ebp
  802151:	89 e5                	mov    %esp,%ebp
  802153:	83 ec 18             	sub    $0x18,%esp
  802156:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802159:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80215c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80215f:	8b 45 08             	mov    0x8(%ebp),%eax
  802162:	89 04 24             	mov    %eax,(%esp)
  802165:	e8 c6 f0 ff ff       	call   801230 <fd2data>
  80216a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80216c:	c7 44 24 04 16 2f 80 	movl   $0x802f16,0x4(%esp)
  802173:	00 
  802174:	89 34 24             	mov    %esi,(%esp)
  802177:	e8 1e e8 ff ff       	call   80099a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80217c:	8b 43 04             	mov    0x4(%ebx),%eax
  80217f:	2b 03                	sub    (%ebx),%eax
  802181:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802187:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80218e:	00 00 00 
	stat->st_dev = &devpipe;
  802191:	c7 86 88 00 00 00 3c 	movl   $0x80603c,0x88(%esi)
  802198:	60 80 00 
	return 0;
}
  80219b:	b8 00 00 00 00       	mov    $0x0,%eax
  8021a0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8021a3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8021a6:	89 ec                	mov    %ebp,%esp
  8021a8:	5d                   	pop    %ebp
  8021a9:	c3                   	ret    

008021aa <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8021aa:	55                   	push   %ebp
  8021ab:	89 e5                	mov    %esp,%ebp
  8021ad:	53                   	push   %ebx
  8021ae:	83 ec 14             	sub    $0x14,%esp
  8021b1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8021b4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8021b8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021bf:	e8 76 ee ff ff       	call   80103a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8021c4:	89 1c 24             	mov    %ebx,(%esp)
  8021c7:	e8 64 f0 ff ff       	call   801230 <fd2data>
  8021cc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021d0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021d7:	e8 5e ee ff ff       	call   80103a <sys_page_unmap>
}
  8021dc:	83 c4 14             	add    $0x14,%esp
  8021df:	5b                   	pop    %ebx
  8021e0:	5d                   	pop    %ebp
  8021e1:	c3                   	ret    

008021e2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  8021e2:	55                   	push   %ebp
  8021e3:	89 e5                	mov    %esp,%ebp
  8021e5:	57                   	push   %edi
  8021e6:	56                   	push   %esi
  8021e7:	53                   	push   %ebx
  8021e8:	83 ec 2c             	sub    $0x2c,%esp
  8021eb:	89 c7                	mov    %eax,%edi
  8021ed:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  8021f0:	a1 74 60 80 00       	mov    0x806074,%eax
  8021f5:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  8021f8:	89 3c 24             	mov    %edi,(%esp)
  8021fb:	e8 b4 05 00 00       	call   8027b4 <pageref>
  802200:	89 c6                	mov    %eax,%esi
  802202:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802205:	89 04 24             	mov    %eax,(%esp)
  802208:	e8 a7 05 00 00       	call   8027b4 <pageref>
  80220d:	39 c6                	cmp    %eax,%esi
  80220f:	0f 94 c0             	sete   %al
  802212:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802215:	8b 15 74 60 80 00    	mov    0x806074,%edx
  80221b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80221e:	39 cb                	cmp    %ecx,%ebx
  802220:	75 08                	jne    80222a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802222:	83 c4 2c             	add    $0x2c,%esp
  802225:	5b                   	pop    %ebx
  802226:	5e                   	pop    %esi
  802227:	5f                   	pop    %edi
  802228:	5d                   	pop    %ebp
  802229:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80222a:	83 f8 01             	cmp    $0x1,%eax
  80222d:	75 c1                	jne    8021f0 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80222f:	8b 52 58             	mov    0x58(%edx),%edx
  802232:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802236:	89 54 24 08          	mov    %edx,0x8(%esp)
  80223a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80223e:	c7 04 24 1d 2f 80 00 	movl   $0x802f1d,(%esp)
  802245:	e8 7f e0 ff ff       	call   8002c9 <cprintf>
  80224a:	eb a4                	jmp    8021f0 <_pipeisclosed+0xe>

0080224c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80224c:	55                   	push   %ebp
  80224d:	89 e5                	mov    %esp,%ebp
  80224f:	57                   	push   %edi
  802250:	56                   	push   %esi
  802251:	53                   	push   %ebx
  802252:	83 ec 1c             	sub    $0x1c,%esp
  802255:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802258:	89 34 24             	mov    %esi,(%esp)
  80225b:	e8 d0 ef ff ff       	call   801230 <fd2data>
  802260:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802262:	bf 00 00 00 00       	mov    $0x0,%edi
  802267:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80226b:	75 54                	jne    8022c1 <devpipe_write+0x75>
  80226d:	eb 60                	jmp    8022cf <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80226f:	89 da                	mov    %ebx,%edx
  802271:	89 f0                	mov    %esi,%eax
  802273:	e8 6a ff ff ff       	call   8021e2 <_pipeisclosed>
  802278:	85 c0                	test   %eax,%eax
  80227a:	74 07                	je     802283 <devpipe_write+0x37>
  80227c:	b8 00 00 00 00       	mov    $0x0,%eax
  802281:	eb 53                	jmp    8022d6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802283:	90                   	nop
  802284:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802288:	e8 c8 ee ff ff       	call   801155 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  80228d:	8b 43 04             	mov    0x4(%ebx),%eax
  802290:	8b 13                	mov    (%ebx),%edx
  802292:	83 c2 20             	add    $0x20,%edx
  802295:	39 d0                	cmp    %edx,%eax
  802297:	73 d6                	jae    80226f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802299:	89 c2                	mov    %eax,%edx
  80229b:	c1 fa 1f             	sar    $0x1f,%edx
  80229e:	c1 ea 1b             	shr    $0x1b,%edx
  8022a1:	01 d0                	add    %edx,%eax
  8022a3:	83 e0 1f             	and    $0x1f,%eax
  8022a6:	29 d0                	sub    %edx,%eax
  8022a8:	89 c2                	mov    %eax,%edx
  8022aa:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8022ad:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  8022b1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  8022b5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8022b9:	83 c7 01             	add    $0x1,%edi
  8022bc:	39 7d 10             	cmp    %edi,0x10(%ebp)
  8022bf:	76 13                	jbe    8022d4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8022c1:	8b 43 04             	mov    0x4(%ebx),%eax
  8022c4:	8b 13                	mov    (%ebx),%edx
  8022c6:	83 c2 20             	add    $0x20,%edx
  8022c9:	39 d0                	cmp    %edx,%eax
  8022cb:	73 a2                	jae    80226f <devpipe_write+0x23>
  8022cd:	eb ca                	jmp    802299 <devpipe_write+0x4d>
  8022cf:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  8022d4:	89 f8                	mov    %edi,%eax
}
  8022d6:	83 c4 1c             	add    $0x1c,%esp
  8022d9:	5b                   	pop    %ebx
  8022da:	5e                   	pop    %esi
  8022db:	5f                   	pop    %edi
  8022dc:	5d                   	pop    %ebp
  8022dd:	c3                   	ret    

008022de <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  8022de:	55                   	push   %ebp
  8022df:	89 e5                	mov    %esp,%ebp
  8022e1:	83 ec 28             	sub    $0x28,%esp
  8022e4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8022e7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8022ea:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8022ed:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  8022f0:	89 3c 24             	mov    %edi,(%esp)
  8022f3:	e8 38 ef ff ff       	call   801230 <fd2data>
  8022f8:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8022fa:	be 00 00 00 00       	mov    $0x0,%esi
  8022ff:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802303:	75 4c                	jne    802351 <devpipe_read+0x73>
  802305:	eb 5b                	jmp    802362 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802307:	89 f0                	mov    %esi,%eax
  802309:	eb 5e                	jmp    802369 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80230b:	89 da                	mov    %ebx,%edx
  80230d:	89 f8                	mov    %edi,%eax
  80230f:	90                   	nop
  802310:	e8 cd fe ff ff       	call   8021e2 <_pipeisclosed>
  802315:	85 c0                	test   %eax,%eax
  802317:	74 07                	je     802320 <devpipe_read+0x42>
  802319:	b8 00 00 00 00       	mov    $0x0,%eax
  80231e:	eb 49                	jmp    802369 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802320:	e8 30 ee ff ff       	call   801155 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802325:	8b 03                	mov    (%ebx),%eax
  802327:	3b 43 04             	cmp    0x4(%ebx),%eax
  80232a:	74 df                	je     80230b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80232c:	89 c2                	mov    %eax,%edx
  80232e:	c1 fa 1f             	sar    $0x1f,%edx
  802331:	c1 ea 1b             	shr    $0x1b,%edx
  802334:	01 d0                	add    %edx,%eax
  802336:	83 e0 1f             	and    $0x1f,%eax
  802339:	29 d0                	sub    %edx,%eax
  80233b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802340:	8b 55 0c             	mov    0xc(%ebp),%edx
  802343:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802346:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802349:	83 c6 01             	add    $0x1,%esi
  80234c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80234f:	76 16                	jbe    802367 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802351:	8b 03                	mov    (%ebx),%eax
  802353:	3b 43 04             	cmp    0x4(%ebx),%eax
  802356:	75 d4                	jne    80232c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802358:	85 f6                	test   %esi,%esi
  80235a:	75 ab                	jne    802307 <devpipe_read+0x29>
  80235c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802360:	eb a9                	jmp    80230b <devpipe_read+0x2d>
  802362:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802367:	89 f0                	mov    %esi,%eax
}
  802369:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80236c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80236f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802372:	89 ec                	mov    %ebp,%esp
  802374:	5d                   	pop    %ebp
  802375:	c3                   	ret    

00802376 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802376:	55                   	push   %ebp
  802377:	89 e5                	mov    %esp,%ebp
  802379:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80237c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80237f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802383:	8b 45 08             	mov    0x8(%ebp),%eax
  802386:	89 04 24             	mov    %eax,(%esp)
  802389:	e8 2f ef ff ff       	call   8012bd <fd_lookup>
  80238e:	85 c0                	test   %eax,%eax
  802390:	78 15                	js     8023a7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802392:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802395:	89 04 24             	mov    %eax,(%esp)
  802398:	e8 93 ee ff ff       	call   801230 <fd2data>
	return _pipeisclosed(fd, p);
  80239d:	89 c2                	mov    %eax,%edx
  80239f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8023a2:	e8 3b fe ff ff       	call   8021e2 <_pipeisclosed>
}
  8023a7:	c9                   	leave  
  8023a8:	c3                   	ret    

008023a9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8023a9:	55                   	push   %ebp
  8023aa:	89 e5                	mov    %esp,%ebp
  8023ac:	83 ec 48             	sub    $0x48,%esp
  8023af:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8023b2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8023b5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8023b8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8023bb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8023be:	89 04 24             	mov    %eax,(%esp)
  8023c1:	e8 85 ee ff ff       	call   80124b <fd_alloc>
  8023c6:	89 c3                	mov    %eax,%ebx
  8023c8:	85 c0                	test   %eax,%eax
  8023ca:	0f 88 42 01 00 00    	js     802512 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8023d0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8023d7:	00 
  8023d8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8023db:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023df:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8023e6:	e8 0b ed ff ff       	call   8010f6 <sys_page_alloc>
  8023eb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8023ed:	85 c0                	test   %eax,%eax
  8023ef:	0f 88 1d 01 00 00    	js     802512 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8023f5:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8023f8:	89 04 24             	mov    %eax,(%esp)
  8023fb:	e8 4b ee ff ff       	call   80124b <fd_alloc>
  802400:	89 c3                	mov    %eax,%ebx
  802402:	85 c0                	test   %eax,%eax
  802404:	0f 88 f5 00 00 00    	js     8024ff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80240a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802411:	00 
  802412:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802415:	89 44 24 04          	mov    %eax,0x4(%esp)
  802419:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802420:	e8 d1 ec ff ff       	call   8010f6 <sys_page_alloc>
  802425:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802427:	85 c0                	test   %eax,%eax
  802429:	0f 88 d0 00 00 00    	js     8024ff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80242f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802432:	89 04 24             	mov    %eax,(%esp)
  802435:	e8 f6 ed ff ff       	call   801230 <fd2data>
  80243a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80243c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802443:	00 
  802444:	89 44 24 04          	mov    %eax,0x4(%esp)
  802448:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80244f:	e8 a2 ec ff ff       	call   8010f6 <sys_page_alloc>
  802454:	89 c3                	mov    %eax,%ebx
  802456:	85 c0                	test   %eax,%eax
  802458:	0f 88 8e 00 00 00    	js     8024ec <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80245e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802461:	89 04 24             	mov    %eax,(%esp)
  802464:	e8 c7 ed ff ff       	call   801230 <fd2data>
  802469:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802470:	00 
  802471:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802475:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80247c:	00 
  80247d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802481:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802488:	e8 0b ec ff ff       	call   801098 <sys_page_map>
  80248d:	89 c3                	mov    %eax,%ebx
  80248f:	85 c0                	test   %eax,%eax
  802491:	78 49                	js     8024dc <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802493:	b8 3c 60 80 00       	mov    $0x80603c,%eax
  802498:	8b 08                	mov    (%eax),%ecx
  80249a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80249d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  80249f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8024a2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8024a9:	8b 10                	mov    (%eax),%edx
  8024ab:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024ae:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8024b0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024b3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8024ba:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8024bd:	89 04 24             	mov    %eax,(%esp)
  8024c0:	e8 5b ed ff ff       	call   801220 <fd2num>
  8024c5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8024c7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024ca:	89 04 24             	mov    %eax,(%esp)
  8024cd:	e8 4e ed ff ff       	call   801220 <fd2num>
  8024d2:	89 47 04             	mov    %eax,0x4(%edi)
  8024d5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  8024da:	eb 36                	jmp    802512 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  8024dc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8024e0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8024e7:	e8 4e eb ff ff       	call   80103a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  8024ec:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024ef:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024f3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8024fa:	e8 3b eb ff ff       	call   80103a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  8024ff:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802502:	89 44 24 04          	mov    %eax,0x4(%esp)
  802506:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80250d:	e8 28 eb ff ff       	call   80103a <sys_page_unmap>
    err:
	return r;
}
  802512:	89 d8                	mov    %ebx,%eax
  802514:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802517:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80251a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80251d:	89 ec                	mov    %ebp,%esp
  80251f:	5d                   	pop    %ebp
  802520:	c3                   	ret    
	...

00802530 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802530:	55                   	push   %ebp
  802531:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802533:	b8 00 00 00 00       	mov    $0x0,%eax
  802538:	5d                   	pop    %ebp
  802539:	c3                   	ret    

0080253a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80253a:	55                   	push   %ebp
  80253b:	89 e5                	mov    %esp,%ebp
  80253d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802540:	c7 44 24 04 35 2f 80 	movl   $0x802f35,0x4(%esp)
  802547:	00 
  802548:	8b 45 0c             	mov    0xc(%ebp),%eax
  80254b:	89 04 24             	mov    %eax,(%esp)
  80254e:	e8 47 e4 ff ff       	call   80099a <strcpy>
	return 0;
}
  802553:	b8 00 00 00 00       	mov    $0x0,%eax
  802558:	c9                   	leave  
  802559:	c3                   	ret    

0080255a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80255a:	55                   	push   %ebp
  80255b:	89 e5                	mov    %esp,%ebp
  80255d:	57                   	push   %edi
  80255e:	56                   	push   %esi
  80255f:	53                   	push   %ebx
  802560:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802566:	b8 00 00 00 00       	mov    $0x0,%eax
  80256b:	be 00 00 00 00       	mov    $0x0,%esi
  802570:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802574:	74 41                	je     8025b7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802576:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80257c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80257f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802581:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802587:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80258c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80258f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802593:	03 45 0c             	add    0xc(%ebp),%eax
  802596:	89 44 24 04          	mov    %eax,0x4(%esp)
  80259a:	89 3c 24             	mov    %edi,(%esp)
  80259d:	e8 b3 e5 ff ff       	call   800b55 <memmove>
		sys_cputs(buf, m);
  8025a2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8025a6:	89 3c 24             	mov    %edi,(%esp)
  8025a9:	e8 e2 e7 ff ff       	call   800d90 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  8025ae:	01 de                	add    %ebx,%esi
  8025b0:	89 f0                	mov    %esi,%eax
  8025b2:	3b 75 10             	cmp    0x10(%ebp),%esi
  8025b5:	72 c5                	jb     80257c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  8025b7:	89 f0                	mov    %esi,%eax
  8025b9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  8025bf:	5b                   	pop    %ebx
  8025c0:	5e                   	pop    %esi
  8025c1:	5f                   	pop    %edi
  8025c2:	5d                   	pop    %ebp
  8025c3:	c3                   	ret    

008025c4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  8025c4:	55                   	push   %ebp
  8025c5:	89 e5                	mov    %esp,%ebp
  8025c7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  8025ca:	8b 45 08             	mov    0x8(%ebp),%eax
  8025cd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  8025d0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8025d7:	00 
  8025d8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8025db:	89 04 24             	mov    %eax,(%esp)
  8025de:	e8 ad e7 ff ff       	call   800d90 <sys_cputs>
}
  8025e3:	c9                   	leave  
  8025e4:	c3                   	ret    

008025e5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  8025e5:	55                   	push   %ebp
  8025e6:	89 e5                	mov    %esp,%ebp
  8025e8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  8025eb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8025ef:	75 07                	jne    8025f8 <devcons_read+0x13>
  8025f1:	eb 2d                	jmp    802620 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8025f3:	e8 5d eb ff ff       	call   801155 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8025f8:	90                   	nop
  8025f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802600:	e8 57 e7 ff ff       	call   800d5c <sys_cgetc>
  802605:	85 c0                	test   %eax,%eax
  802607:	74 ea                	je     8025f3 <devcons_read+0xe>
  802609:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  80260b:	85 c0                	test   %eax,%eax
  80260d:	78 16                	js     802625 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  80260f:	83 f8 04             	cmp    $0x4,%eax
  802612:	74 0c                	je     802620 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802614:	8b 45 0c             	mov    0xc(%ebp),%eax
  802617:	88 10                	mov    %dl,(%eax)
  802619:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  80261e:	eb 05                	jmp    802625 <devcons_read+0x40>
  802620:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802625:	c9                   	leave  
  802626:	c3                   	ret    

00802627 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802627:	55                   	push   %ebp
  802628:	89 e5                	mov    %esp,%ebp
  80262a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  80262d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802630:	89 04 24             	mov    %eax,(%esp)
  802633:	e8 13 ec ff ff       	call   80124b <fd_alloc>
  802638:	85 c0                	test   %eax,%eax
  80263a:	78 3f                	js     80267b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  80263c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802643:	00 
  802644:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802647:	89 44 24 04          	mov    %eax,0x4(%esp)
  80264b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802652:	e8 9f ea ff ff       	call   8010f6 <sys_page_alloc>
  802657:	85 c0                	test   %eax,%eax
  802659:	78 20                	js     80267b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  80265b:	8b 15 58 60 80 00    	mov    0x806058,%edx
  802661:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802664:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802666:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802669:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802670:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802673:	89 04 24             	mov    %eax,(%esp)
  802676:	e8 a5 eb ff ff       	call   801220 <fd2num>
}
  80267b:	c9                   	leave  
  80267c:	c3                   	ret    

0080267d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80267d:	55                   	push   %ebp
  80267e:	89 e5                	mov    %esp,%ebp
  802680:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802683:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802686:	89 44 24 04          	mov    %eax,0x4(%esp)
  80268a:	8b 45 08             	mov    0x8(%ebp),%eax
  80268d:	89 04 24             	mov    %eax,(%esp)
  802690:	e8 28 ec ff ff       	call   8012bd <fd_lookup>
  802695:	85 c0                	test   %eax,%eax
  802697:	78 11                	js     8026aa <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802699:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80269c:	8b 00                	mov    (%eax),%eax
  80269e:	3b 05 58 60 80 00    	cmp    0x806058,%eax
  8026a4:	0f 94 c0             	sete   %al
  8026a7:	0f b6 c0             	movzbl %al,%eax
}
  8026aa:	c9                   	leave  
  8026ab:	c3                   	ret    

008026ac <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  8026ac:	55                   	push   %ebp
  8026ad:	89 e5                	mov    %esp,%ebp
  8026af:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  8026b2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  8026b9:	00 
  8026ba:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8026bd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026c1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026c8:	e8 56 ee ff ff       	call   801523 <read>
	if (r < 0)
  8026cd:	85 c0                	test   %eax,%eax
  8026cf:	78 0f                	js     8026e0 <getchar+0x34>
		return r;
	if (r < 1)
  8026d1:	85 c0                	test   %eax,%eax
  8026d3:	7f 07                	jg     8026dc <getchar+0x30>
  8026d5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  8026da:	eb 04                	jmp    8026e0 <getchar+0x34>
		return -E_EOF;
	return c;
  8026dc:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8026e0:	c9                   	leave  
  8026e1:	c3                   	ret    
	...

008026f0 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  8026f0:	55                   	push   %ebp
  8026f1:	89 e5                	mov    %esp,%ebp
  8026f3:	57                   	push   %edi
  8026f4:	56                   	push   %esi
  8026f5:	53                   	push   %ebx
  8026f6:	83 ec 2c             	sub    $0x2c,%esp
  8026f9:	8b 75 08             	mov    0x8(%ebp),%esi
  8026fc:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8026ff:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802702:	85 db                	test   %ebx,%ebx
  802704:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802709:	0f 45 c3             	cmovne %ebx,%eax
  80270c:	8b 55 14             	mov    0x14(%ebp),%edx
  80270f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802713:	89 44 24 08          	mov    %eax,0x8(%esp)
  802717:	89 7c 24 04          	mov    %edi,0x4(%esp)
  80271b:	89 34 24             	mov    %esi,(%esp)
  80271e:	e8 9d e7 ff ff       	call   800ec0 <sys_ipc_try_send>
  802723:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802726:	75 0a                	jne    802732 <ipc_send+0x42>
      sys_yield();
  802728:	e8 28 ea ff ff       	call   801155 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  80272d:	8d 76 00             	lea    0x0(%esi),%esi
  802730:	eb d0                	jmp    802702 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802732:	85 c0                	test   %eax,%eax
  802734:	79 24                	jns    80275a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802736:	89 44 24 10          	mov    %eax,0x10(%esp)
  80273a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80273e:	c7 44 24 08 44 2f 80 	movl   $0x802f44,0x8(%esp)
  802745:	00 
  802746:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80274d:	00 
  80274e:	c7 04 24 68 2f 80 00 	movl   $0x802f68,(%esp)
  802755:	e8 aa da ff ff       	call   800204 <_panic>
    else
      return;
  }
}
  80275a:	83 c4 2c             	add    $0x2c,%esp
  80275d:	5b                   	pop    %ebx
  80275e:	5e                   	pop    %esi
  80275f:	5f                   	pop    %edi
  802760:	5d                   	pop    %ebp
  802761:	c3                   	ret    

00802762 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802762:	55                   	push   %ebp
  802763:	89 e5                	mov    %esp,%ebp
  802765:	56                   	push   %esi
  802766:	53                   	push   %ebx
  802767:	83 ec 10             	sub    $0x10,%esp
  80276a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80276d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802770:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802773:	85 c0                	test   %eax,%eax
  802775:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  80277a:	0f 44 c2             	cmove  %edx,%eax
  80277d:	89 04 24             	mov    %eax,(%esp)
  802780:	e8 de e6 ff ff       	call   800e63 <sys_ipc_recv>
  802785:	85 c0                	test   %eax,%eax
  802787:	78 24                	js     8027ad <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802789:	85 db                	test   %ebx,%ebx
  80278b:	74 0a                	je     802797 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  80278d:	a1 74 60 80 00       	mov    0x806074,%eax
  802792:	8b 40 74             	mov    0x74(%eax),%eax
  802795:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802797:	85 f6                	test   %esi,%esi
  802799:	74 0a                	je     8027a5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  80279b:	a1 74 60 80 00       	mov    0x806074,%eax
  8027a0:	8b 40 78             	mov    0x78(%eax),%eax
  8027a3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  8027a5:	a1 74 60 80 00       	mov    0x806074,%eax
  8027aa:	8b 40 70             	mov    0x70(%eax),%eax
}
  8027ad:	83 c4 10             	add    $0x10,%esp
  8027b0:	5b                   	pop    %ebx
  8027b1:	5e                   	pop    %esi
  8027b2:	5d                   	pop    %ebp
  8027b3:	c3                   	ret    

008027b4 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  8027b4:	55                   	push   %ebp
  8027b5:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  8027b7:	8b 45 08             	mov    0x8(%ebp),%eax
  8027ba:	89 c2                	mov    %eax,%edx
  8027bc:	c1 ea 16             	shr    $0x16,%edx
  8027bf:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8027c6:	f6 c2 01             	test   $0x1,%dl
  8027c9:	74 26                	je     8027f1 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  8027cb:	c1 e8 0c             	shr    $0xc,%eax
  8027ce:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  8027d5:	a8 01                	test   $0x1,%al
  8027d7:	74 18                	je     8027f1 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  8027d9:	c1 e8 0c             	shr    $0xc,%eax
  8027dc:	8d 14 40             	lea    (%eax,%eax,2),%edx
  8027df:	c1 e2 02             	shl    $0x2,%edx
  8027e2:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  8027e7:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  8027ec:	0f b7 c0             	movzwl %ax,%eax
  8027ef:	eb 05                	jmp    8027f6 <pageref+0x42>
  8027f1:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8027f6:	5d                   	pop    %ebp
  8027f7:	c3                   	ret    
	...

00802800 <__udivdi3>:
  802800:	55                   	push   %ebp
  802801:	89 e5                	mov    %esp,%ebp
  802803:	57                   	push   %edi
  802804:	56                   	push   %esi
  802805:	83 ec 10             	sub    $0x10,%esp
  802808:	8b 45 14             	mov    0x14(%ebp),%eax
  80280b:	8b 55 08             	mov    0x8(%ebp),%edx
  80280e:	8b 75 10             	mov    0x10(%ebp),%esi
  802811:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802814:	85 c0                	test   %eax,%eax
  802816:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802819:	75 35                	jne    802850 <__udivdi3+0x50>
  80281b:	39 fe                	cmp    %edi,%esi
  80281d:	77 61                	ja     802880 <__udivdi3+0x80>
  80281f:	85 f6                	test   %esi,%esi
  802821:	75 0b                	jne    80282e <__udivdi3+0x2e>
  802823:	b8 01 00 00 00       	mov    $0x1,%eax
  802828:	31 d2                	xor    %edx,%edx
  80282a:	f7 f6                	div    %esi
  80282c:	89 c6                	mov    %eax,%esi
  80282e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802831:	31 d2                	xor    %edx,%edx
  802833:	89 f8                	mov    %edi,%eax
  802835:	f7 f6                	div    %esi
  802837:	89 c7                	mov    %eax,%edi
  802839:	89 c8                	mov    %ecx,%eax
  80283b:	f7 f6                	div    %esi
  80283d:	89 c1                	mov    %eax,%ecx
  80283f:	89 fa                	mov    %edi,%edx
  802841:	89 c8                	mov    %ecx,%eax
  802843:	83 c4 10             	add    $0x10,%esp
  802846:	5e                   	pop    %esi
  802847:	5f                   	pop    %edi
  802848:	5d                   	pop    %ebp
  802849:	c3                   	ret    
  80284a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802850:	39 f8                	cmp    %edi,%eax
  802852:	77 1c                	ja     802870 <__udivdi3+0x70>
  802854:	0f bd d0             	bsr    %eax,%edx
  802857:	83 f2 1f             	xor    $0x1f,%edx
  80285a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80285d:	75 39                	jne    802898 <__udivdi3+0x98>
  80285f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802862:	0f 86 a0 00 00 00    	jbe    802908 <__udivdi3+0x108>
  802868:	39 f8                	cmp    %edi,%eax
  80286a:	0f 82 98 00 00 00    	jb     802908 <__udivdi3+0x108>
  802870:	31 ff                	xor    %edi,%edi
  802872:	31 c9                	xor    %ecx,%ecx
  802874:	89 c8                	mov    %ecx,%eax
  802876:	89 fa                	mov    %edi,%edx
  802878:	83 c4 10             	add    $0x10,%esp
  80287b:	5e                   	pop    %esi
  80287c:	5f                   	pop    %edi
  80287d:	5d                   	pop    %ebp
  80287e:	c3                   	ret    
  80287f:	90                   	nop
  802880:	89 d1                	mov    %edx,%ecx
  802882:	89 fa                	mov    %edi,%edx
  802884:	89 c8                	mov    %ecx,%eax
  802886:	31 ff                	xor    %edi,%edi
  802888:	f7 f6                	div    %esi
  80288a:	89 c1                	mov    %eax,%ecx
  80288c:	89 fa                	mov    %edi,%edx
  80288e:	89 c8                	mov    %ecx,%eax
  802890:	83 c4 10             	add    $0x10,%esp
  802893:	5e                   	pop    %esi
  802894:	5f                   	pop    %edi
  802895:	5d                   	pop    %ebp
  802896:	c3                   	ret    
  802897:	90                   	nop
  802898:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  80289c:	89 f2                	mov    %esi,%edx
  80289e:	d3 e0                	shl    %cl,%eax
  8028a0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8028a3:	b8 20 00 00 00       	mov    $0x20,%eax
  8028a8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  8028ab:	89 c1                	mov    %eax,%ecx
  8028ad:	d3 ea                	shr    %cl,%edx
  8028af:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8028b3:	0b 55 ec             	or     -0x14(%ebp),%edx
  8028b6:	d3 e6                	shl    %cl,%esi
  8028b8:	89 c1                	mov    %eax,%ecx
  8028ba:	89 75 e8             	mov    %esi,-0x18(%ebp)
  8028bd:	89 fe                	mov    %edi,%esi
  8028bf:	d3 ee                	shr    %cl,%esi
  8028c1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8028c5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8028c8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8028cb:	d3 e7                	shl    %cl,%edi
  8028cd:	89 c1                	mov    %eax,%ecx
  8028cf:	d3 ea                	shr    %cl,%edx
  8028d1:	09 d7                	or     %edx,%edi
  8028d3:	89 f2                	mov    %esi,%edx
  8028d5:	89 f8                	mov    %edi,%eax
  8028d7:	f7 75 ec             	divl   -0x14(%ebp)
  8028da:	89 d6                	mov    %edx,%esi
  8028dc:	89 c7                	mov    %eax,%edi
  8028de:	f7 65 e8             	mull   -0x18(%ebp)
  8028e1:	39 d6                	cmp    %edx,%esi
  8028e3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8028e6:	72 30                	jb     802918 <__udivdi3+0x118>
  8028e8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8028eb:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8028ef:	d3 e2                	shl    %cl,%edx
  8028f1:	39 c2                	cmp    %eax,%edx
  8028f3:	73 05                	jae    8028fa <__udivdi3+0xfa>
  8028f5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  8028f8:	74 1e                	je     802918 <__udivdi3+0x118>
  8028fa:	89 f9                	mov    %edi,%ecx
  8028fc:	31 ff                	xor    %edi,%edi
  8028fe:	e9 71 ff ff ff       	jmp    802874 <__udivdi3+0x74>
  802903:	90                   	nop
  802904:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802908:	31 ff                	xor    %edi,%edi
  80290a:	b9 01 00 00 00       	mov    $0x1,%ecx
  80290f:	e9 60 ff ff ff       	jmp    802874 <__udivdi3+0x74>
  802914:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802918:	8d 4f ff             	lea    -0x1(%edi),%ecx
  80291b:	31 ff                	xor    %edi,%edi
  80291d:	89 c8                	mov    %ecx,%eax
  80291f:	89 fa                	mov    %edi,%edx
  802921:	83 c4 10             	add    $0x10,%esp
  802924:	5e                   	pop    %esi
  802925:	5f                   	pop    %edi
  802926:	5d                   	pop    %ebp
  802927:	c3                   	ret    
	...

00802930 <__umoddi3>:
  802930:	55                   	push   %ebp
  802931:	89 e5                	mov    %esp,%ebp
  802933:	57                   	push   %edi
  802934:	56                   	push   %esi
  802935:	83 ec 20             	sub    $0x20,%esp
  802938:	8b 55 14             	mov    0x14(%ebp),%edx
  80293b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80293e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802941:	8b 75 0c             	mov    0xc(%ebp),%esi
  802944:	85 d2                	test   %edx,%edx
  802946:	89 c8                	mov    %ecx,%eax
  802948:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  80294b:	75 13                	jne    802960 <__umoddi3+0x30>
  80294d:	39 f7                	cmp    %esi,%edi
  80294f:	76 3f                	jbe    802990 <__umoddi3+0x60>
  802951:	89 f2                	mov    %esi,%edx
  802953:	f7 f7                	div    %edi
  802955:	89 d0                	mov    %edx,%eax
  802957:	31 d2                	xor    %edx,%edx
  802959:	83 c4 20             	add    $0x20,%esp
  80295c:	5e                   	pop    %esi
  80295d:	5f                   	pop    %edi
  80295e:	5d                   	pop    %ebp
  80295f:	c3                   	ret    
  802960:	39 f2                	cmp    %esi,%edx
  802962:	77 4c                	ja     8029b0 <__umoddi3+0x80>
  802964:	0f bd ca             	bsr    %edx,%ecx
  802967:	83 f1 1f             	xor    $0x1f,%ecx
  80296a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  80296d:	75 51                	jne    8029c0 <__umoddi3+0x90>
  80296f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802972:	0f 87 e0 00 00 00    	ja     802a58 <__umoddi3+0x128>
  802978:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80297b:	29 f8                	sub    %edi,%eax
  80297d:	19 d6                	sbb    %edx,%esi
  80297f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802982:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802985:	89 f2                	mov    %esi,%edx
  802987:	83 c4 20             	add    $0x20,%esp
  80298a:	5e                   	pop    %esi
  80298b:	5f                   	pop    %edi
  80298c:	5d                   	pop    %ebp
  80298d:	c3                   	ret    
  80298e:	66 90                	xchg   %ax,%ax
  802990:	85 ff                	test   %edi,%edi
  802992:	75 0b                	jne    80299f <__umoddi3+0x6f>
  802994:	b8 01 00 00 00       	mov    $0x1,%eax
  802999:	31 d2                	xor    %edx,%edx
  80299b:	f7 f7                	div    %edi
  80299d:	89 c7                	mov    %eax,%edi
  80299f:	89 f0                	mov    %esi,%eax
  8029a1:	31 d2                	xor    %edx,%edx
  8029a3:	f7 f7                	div    %edi
  8029a5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8029a8:	f7 f7                	div    %edi
  8029aa:	eb a9                	jmp    802955 <__umoddi3+0x25>
  8029ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8029b0:	89 c8                	mov    %ecx,%eax
  8029b2:	89 f2                	mov    %esi,%edx
  8029b4:	83 c4 20             	add    $0x20,%esp
  8029b7:	5e                   	pop    %esi
  8029b8:	5f                   	pop    %edi
  8029b9:	5d                   	pop    %ebp
  8029ba:	c3                   	ret    
  8029bb:	90                   	nop
  8029bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8029c0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8029c4:	d3 e2                	shl    %cl,%edx
  8029c6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8029c9:	ba 20 00 00 00       	mov    $0x20,%edx
  8029ce:	2b 55 f0             	sub    -0x10(%ebp),%edx
  8029d1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8029d4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8029d8:	89 fa                	mov    %edi,%edx
  8029da:	d3 ea                	shr    %cl,%edx
  8029dc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8029e0:	0b 55 f4             	or     -0xc(%ebp),%edx
  8029e3:	d3 e7                	shl    %cl,%edi
  8029e5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8029e9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8029ec:	89 f2                	mov    %esi,%edx
  8029ee:	89 7d e8             	mov    %edi,-0x18(%ebp)
  8029f1:	89 c7                	mov    %eax,%edi
  8029f3:	d3 ea                	shr    %cl,%edx
  8029f5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8029f9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8029fc:	89 c2                	mov    %eax,%edx
  8029fe:	d3 e6                	shl    %cl,%esi
  802a00:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802a04:	d3 ea                	shr    %cl,%edx
  802a06:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a0a:	09 d6                	or     %edx,%esi
  802a0c:	89 f0                	mov    %esi,%eax
  802a0e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802a11:	d3 e7                	shl    %cl,%edi
  802a13:	89 f2                	mov    %esi,%edx
  802a15:	f7 75 f4             	divl   -0xc(%ebp)
  802a18:	89 d6                	mov    %edx,%esi
  802a1a:	f7 65 e8             	mull   -0x18(%ebp)
  802a1d:	39 d6                	cmp    %edx,%esi
  802a1f:	72 2b                	jb     802a4c <__umoddi3+0x11c>
  802a21:	39 c7                	cmp    %eax,%edi
  802a23:	72 23                	jb     802a48 <__umoddi3+0x118>
  802a25:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a29:	29 c7                	sub    %eax,%edi
  802a2b:	19 d6                	sbb    %edx,%esi
  802a2d:	89 f0                	mov    %esi,%eax
  802a2f:	89 f2                	mov    %esi,%edx
  802a31:	d3 ef                	shr    %cl,%edi
  802a33:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802a37:	d3 e0                	shl    %cl,%eax
  802a39:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a3d:	09 f8                	or     %edi,%eax
  802a3f:	d3 ea                	shr    %cl,%edx
  802a41:	83 c4 20             	add    $0x20,%esp
  802a44:	5e                   	pop    %esi
  802a45:	5f                   	pop    %edi
  802a46:	5d                   	pop    %ebp
  802a47:	c3                   	ret    
  802a48:	39 d6                	cmp    %edx,%esi
  802a4a:	75 d9                	jne    802a25 <__umoddi3+0xf5>
  802a4c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802a4f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802a52:	eb d1                	jmp    802a25 <__umoddi3+0xf5>
  802a54:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802a58:	39 f2                	cmp    %esi,%edx
  802a5a:	0f 82 18 ff ff ff    	jb     802978 <__umoddi3+0x48>
  802a60:	e9 1d ff ff ff       	jmp    802982 <__umoddi3+0x52>
